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