performQuery method

Future<QueryResult<Object?>?> performQuery(
  1. String gqlQuery,
  2. Map<String, dynamic> variables, [
  3. String? token
])

Implementation

Future<QueryResult?> performQuery(
    String gqlQuery, Map<String, dynamic> variables,
    [String? token]) async {
  requestCounter++;

  try {
    GraphQLClient _client = await getClient(token);

    QueryResult result = await _client.query(QueryOptions(
        document: gql(gqlQuery),
        variables: variables,
        fetchPolicy: FetchPolicy.networkOnly));

    if (result.hasException) {
      if (kDebugMode) {
        print(
            "Exception while performing query: ${result.exception.toString()}");
      }

      return null;
    }
    return result;
  } catch (e) {
    if (kDebugMode) {
      print("Error while performing query: $e");
    }

    return null;
  }
}