customQuery method

Future<Map<String, dynamic>?> customQuery({
  1. required String gqlQuery,
  2. Map<String, dynamic> variables = const {},
  3. bool adminAccess = false,
})

Returns a Map of String and dynamic.

Returns the data of the custom query.

adminAccess is optional, if set to true, the admin access token will be used.

Implementation

Future<Map<String, dynamic>?> customQuery({
  required String gqlQuery,
  Map<String, dynamic> variables = const {},
  bool adminAccess = false,
}) async {
  final QueryOptions _options = WatchQueryOptions(
    document: gql(gqlQuery),
    variables: variables,
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  final QueryResult result = adminAccess
      ? await _graphQLClientAdmin!.query(_options)
      : await _graphQLClient!.query(_options);
  checkForError(result);
  return result.data;
}