gqlAuthMutation method
Future gqlAuthMutation (String mutation, {Map<String, dynamic>? variables})
This function is used to run the graph-ql mutation for authenticated user.
params:
mutation
: mutation is used to change/add/delete data in graphql, for more info read graphql docsvariables
: variables to be passed with mutation
returns:
Future<dynamic>
: it returns Future of dynamic
Implementation
Future<dynamic> gqlAuthMutation(
String mutation, {
Map<String, dynamic>? variables,
}) async {
final QueryResult result = await clientAuth.mutate(
MutationOptions(
document: gql(mutation),
variables: variables ?? <String, dynamic>{},
),
);
// if there is an error or exception in [result]
if (result.hasException) {
final exception = encounteredExceptionOrError(result.exception!);
if (exception!) {
gqlAuthMutation(mutation, variables: variables);
}
} else if (result.data != null && result.isConcrete) {
return result;
}
return null;
}