Example #1
0
        /// <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)
        {
            //== JT: set the Operation Type
            schemaProvider.OperationType = OperationType.Mutation;
            //==
            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();
            }
            this.currentExpressionContext = (ExpressionResult)Expression.Parameter(schemaProvider.ContextType, $"ctx");
            var mutateFields = new List <IGraphQLBaseNode>();

            foreach (var c in context.objectSelection().children)
            {
                var n = Visit(c);
                if (n != null)
                {
                    mutateFields.Add(n);
                }
            }
            var mutation = new GraphQLQueryNode(schemaProvider, fragments, operation.Name, null, null, mutateFields, null);

            return(mutation);
        }
Example #2
0
        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);
        }