callAPI static method

Future callAPI({
  1. required String queryString,
  2. required Map<String, dynamic> variables,
  3. required IGraphQlClient graphClient,
  4. bool raw = false,
})

callAPI method to call graphQL API

Implementation

static Future<dynamic> callAPI({
  required String queryString,
  required Map<String, dynamic> variables,
  required IGraphQlClient graphClient,
  bool raw = false,
}) async {
  final Response result = await graphClient.query(queryString, variables);

  // returns the raw http response without preprocessing
  if (raw) {
    return result;
  }

  final Map<String, dynamic> body = graphClient.toMap(result);

  if (graphClient.parseError(body) != null) {
    return <String, dynamic>{'error': graphClient.parseError(body)};
  } else {
    return body;
  }
}