Skip to main content

gqlNonAuthMutation method

Future gqlNonAuthMutation (String mutation, {Map<String, dynamic>? variables, bool reCall = true})

This function is used to run the graph-ql mutation to authenticate the non signed-in user.

params:

  • mutation: mutation is used to change/add/delete data in graphql, for more info read graphql docs
  • variables: variables to be passed with mutation
  • reCall: when not first fetch call

returns:

  • Future<dynamic>: it returns Future of dynamic

Implementation

Future<dynamic> gqlNonAuthMutation(
String mutation, {
Map<String, dynamic>? variables,
bool reCall = true,
}) async {
final QueryResult result = await clientNonAuth.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! && reCall) {
gqlNonAuthMutation(mutation, variables: variables);
}
} else if (result.data != null && result.isConcrete) {
return result;
}
return null;
}