Skip to main content

gqlNonAuthQuery method

Future<QueryResult<Object?>?> gqlNonAuthQuery (String query, {Map<String, dynamic>? variables})

<p>This function is used to run the graph-ql query for the non signed-in user.</p> <p><strong>params</strong>:</p> <ul> <li><code>query</code>: query is used to fetch data in graphql, for more info read graphql docs</li> <li><code>variables</code>: variables to be passed with query</li> </ul> <p><strong>returns</strong>:</p> <ul> <li><code>Future<QueryResult<Object?>?></code>: it returns Future of QueryResult, contains all data</li> </ul>

Implementation

Future\<QueryResult\<Object?\>?\> gqlNonAuthQuery(
String query, \{
Map\<String, dynamic\>? variables,
\}) async \{
final queryOptions = QueryOptions(
document: gql(query),
variables: variables ?? \<String, dynamic\>\{\},
);
final result = await clientNonAuth.query(queryOptions);
QueryResult? finalRes;
if there is an error or exception in [result]
if (result.hasException) \{
final exception = encounteredExceptionOrError(result.exception!);
if (exception!) \{
finalRes = await gqlNonAuthQuery(query, variables: variables);
\}
\} else if (result.data != null && result.isConcrete) \{
return result;
\}
return finalRes;
\}