parseAndExecute method Null safety

Future parseAndExecute(
  1. String text,
  2. {String? operationName,
  3. dynamic sourceUrl,
  4. Map<String, dynamic> variableValues = const {},
  5. dynamic initialValue,
  6. Map<String, dynamic> globalVariables = const {}}
)

Implementation

Future parseAndExecute(String text,
    {String? operationName,
    sourceUrl,
    Map<String, dynamic> variableValues = const {},
    initialValue,
    Map<String, dynamic> globalVariables = const {}}) {
  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,
  );
}