parseAndExecute method

Future parseAndExecute (String text, { String operationName, dynamic sourceUrl, Map<String, dynamic> variableValues: const {}, dynamic initialValue, Map<String, dynamic> globalVariables })

Implementation

Future parseAndExecute(String text,
    {String operationName,
    sourceUrl,
    Map<String, dynamic> variableValues = const {},
    initialValue,
    Map<String, dynamic> globalVariables}) {
  var tokens = scan(text, sourceUrl: sourceUrl);
  var parser = Parser(tokens);
  var document = parser.parseDocument();

  if (parser.errors.isNotEmpty) {
    throw GraphQLException(parser.errors
        .map((e) => GraphQLExceptionError(e.message, locations: [
              GraphExceptionErrorLocation.fromSourceLocation(e.span.start)
            ]))
        .toList());
  }

  return executeRequest(
    _schema,
    document,
    operationName: operationName,
    initialValue: initialValue,
    variableValues: variableValues,
    globalVariables: globalVariables,
  );
}