From 0a1928cf26154fa8bd080522f9b51329b7d59736 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 3 Aug 2018 21:29:53 -0400 Subject: [PATCH] Added executeMutation --- graphql_server/lib/graphql_server.dart | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/graphql_server/lib/graphql_server.dart b/graphql_server/lib/graphql_server.dart index e911cd3b..be693929 100644 --- a/graphql_server/lib/graphql_server.dart +++ b/graphql_server/lib/graphql_server.dart @@ -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> executeMutation( + DocumentContext document, + OperationDefinitionContext mutation, + GraphQLSchema schema, + Map 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> executeSelectionSet( DocumentContext document, SelectionSetContext selectionSet,