callAPI static method
Future
callAPI({
- required String queryString,
- required Map<
String, dynamic> variables, - required IGraphQlClient graphClient,
- 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;
}
}