public override IGraphQLNode VisitMutationQuery(EntityGraphQLParser.MutationQueryContext context) { var root = new GraphQLNode("root", null, null, null, null); var operationName = GetOperationName(context.operationName()); foreach (var c in context.gqlBody().children) { var mutation = Visit(c); if (mutation != null) { root.Fields.Add(mutation); } } return(root); }
/// <summary> /// This is one of our top level node. /// mutation MyMutation {...} /// </summary> /// <param name="context"></param> /// <returns></returns> public override IGraphQLBaseNode VisitMutationQuery(EntityGraphQLParser.MutationQueryContext context) { var operation = GetOperation(context.operationName()); foreach (var item in operation.Arguments.Where(a => a.DefaultValue != null)) { variables[item.ArgName] = Expression.Lambda(item.DefaultValue.Expression).Compile().DynamicInvoke(); } var mutation = new GraphQLNode(schemaProvider, fragments, operation.Name, null, null, null, null, null); foreach (var c in context.gqlBody().children) { var n = Visit(c); if (n != null) { mutation.AddField((IGraphQLNode)n); } } rootQueries.Add(mutation); return(mutation); }