Added executeMutation

This commit is contained in:
Tobe O 2018-08-03 21:29:53 -04:00
parent d96470a62a
commit 0a1928cf26

View file

@ -94,9 +94,8 @@ class GraphQL {
return await executeQuery(
document, operation, schema, coercedVariableValues, initialValue);
else {
throw new UnimplementedError('mutations');
// return executeMutation(
// document, operation, schema, coercedVariableValues, initialValue);
return executeMutation(
document, operation, schema, coercedVariableValues, initialValue);
}
}
@ -173,6 +172,23 @@ class GraphQL {
document, selectionSet, queryType, initialValue, variableValues);
}
Future<Map<String, dynamic>> executeMutation(
DocumentContext document,
OperationDefinitionContext mutation,
GraphQLSchema schema,
Map<String, dynamic> variableValues,
initialValue) async {
var mutationType = schema.mutation;
if (mutationType == null) {
throw new GraphQLException.fromMessage('The schema does not define a mutation type.');
}
var selectionSet = mutation.selectionSet;
return await executeSelectionSet(
document, selectionSet, mutationType, initialValue, variableValues);
}
Future<Map<String, dynamic>> executeSelectionSet(
DocumentContext document,
SelectionSetContext selectionSet,