Beispiel #1
0
        private static IResolveFieldContext CreateResolveFieldContext(ISchema schema, string query)
        {
            var documentBuilder = new GraphQLDocumentBuilder();
            var document        = documentBuilder.Build(query);

            schema.Initialize();

            var executionContext = new ExecutionContext
            {
                Document  = document,
                Schema    = schema,
                Fragments = document.Fragments,
                Operation = document.Operations.First()
            };

            var root = new RootExecutionNode(schema.Query)
            {
                Result = executionContext.RootValue
            };

            var fields = ExecutionHelper.CollectFields(executionContext, schema.Query, executionContext.Operation.SelectionSet);

            ExecutionStrategy.SetSubFieldNodes(executionContext, root, fields);

            var subNode = root.SubFields.FirstOrDefault();

            return(new ReadonlyResolveFieldContext(subNode.Value, executionContext));
        }
Beispiel #2
0
        public static RootExecutionNode ToExecutionTree(this IReadOnlyDictionary <string, object> dictionary)
        {
            var root = new RootExecutionNode(null, null)
            {
                SubFields = dictionary.Select(x => CreateExecutionNode(x.Key, x.Value)).ToArray()
            };

            return(root);
        }
Beispiel #3
0
        public void RootExecutionNode_Should_Not_Throw_Exceptions()
        {
            var type = new ObjectGraphType();
            var root = new RootExecutionNode(type);

            root.Field.ShouldBeNull();
            root.FieldDefinition.ShouldBeNull();
            root.GetHashCode().ShouldNotBe(0);
            root.GetObjectGraphType(null).ShouldBe(type);
            root.GetParentType(null).ShouldBeNull();
            root.GraphType.ShouldBe(type);
            root.IndexInParentNode.ShouldBeNull();
            root.Name.ShouldBeNull();
            root.Parent.ShouldBeNull();
            root.Path.ToArray().Length.ShouldBe(0);
            root.ResolvedType.ShouldBeNull();
            root.ResponsePath.ToArray().Length.ShouldBe(0);
            root.Result.ShouldBeNull();
            root.Source.ShouldBeNull();
            root.SubFields.ShouldBeNull();
            root.ToString().ShouldNotBeNull();
            root.ToValue().ShouldBeNull();
        }