Search in sources :

Example 1 with NodeTraverser

use of graphql.language.NodeTraverser in project graphql-java by graphql-java.

the class QueryTraversal method visitImpl.

private void visitImpl(FieldVisitor visitFieldCallback, SelectionSet selectionSet, GraphQLCompositeType type, boolean preOrder) {
    Map<Class<?>, Object> rootVars = new LinkedHashMap<>();
    rootVars.put(QueryTraversalContext.class, new QueryTraversalContext(type, null));
    FieldVisitor noOp = notUsed -> {
    };
    FieldVisitor preOrderCallback = preOrder ? visitFieldCallback : noOp;
    FieldVisitor postOrderCallback = !preOrder ? visitFieldCallback : noOp;
    NodeTraverser nodeTraverser = new NodeTraverser(rootVars, this::childrenOf);
    nodeTraverser.depthFirst(new NodeVisitorImpl(preOrderCallback, postOrderCallback), selectionSet.getSelections());
}
Also used : OperationDefinition(graphql.language.OperationDefinition) Internal(graphql.Internal) Node(graphql.language.Node) NodeUtil(graphql.language.NodeUtil) TraversalControl(graphql.util.TraversalControl) ValuesResolver(graphql.execution.ValuesResolver) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) FragmentSpread(graphql.language.FragmentSpread) LeaveOrEnter(graphql.language.NodeTraverser.LeaveOrEnter) TraverserContext(graphql.util.TraverserContext) Introspection(graphql.introspection.Introspection) LinkedHashMap(java.util.LinkedHashMap) Selection(graphql.language.Selection) Assert.assertShouldNeverHappen(graphql.Assert.assertShouldNeverHappen) NodeTraverser(graphql.language.NodeTraverser) Map(java.util.Map) GraphQLCompositeType(graphql.schema.GraphQLCompositeType) GraphQLSchema(graphql.schema.GraphQLSchema) TypeName(graphql.language.TypeName) SelectionSet(graphql.language.SelectionSet) GraphQLObjectType(graphql.schema.GraphQLObjectType) NodeVisitorStub(graphql.language.NodeVisitorStub) GraphQLUnmodifiedType(graphql.schema.GraphQLUnmodifiedType) Field(graphql.language.Field) SchemaUtil(graphql.schema.SchemaUtil) Document(graphql.language.Document) List(java.util.List) LEAVE(graphql.language.NodeTraverser.LeaveOrEnter.LEAVE) Assert.assertNotNull(graphql.Assert.assertNotNull) ConditionalNodes(graphql.execution.ConditionalNodes) FragmentDefinition(graphql.language.FragmentDefinition) InlineFragment(graphql.language.InlineFragment) NodeTraverser(graphql.language.NodeTraverser) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Assert.assertNotNull (graphql.Assert.assertNotNull)1 Assert.assertShouldNeverHappen (graphql.Assert.assertShouldNeverHappen)1 Internal (graphql.Internal)1 ConditionalNodes (graphql.execution.ConditionalNodes)1 ValuesResolver (graphql.execution.ValuesResolver)1 Introspection (graphql.introspection.Introspection)1 Document (graphql.language.Document)1 Field (graphql.language.Field)1 FragmentDefinition (graphql.language.FragmentDefinition)1 FragmentSpread (graphql.language.FragmentSpread)1 InlineFragment (graphql.language.InlineFragment)1 Node (graphql.language.Node)1 NodeTraverser (graphql.language.NodeTraverser)1 LeaveOrEnter (graphql.language.NodeTraverser.LeaveOrEnter)1 LEAVE (graphql.language.NodeTraverser.LeaveOrEnter.LEAVE)1 NodeUtil (graphql.language.NodeUtil)1 NodeVisitorStub (graphql.language.NodeVisitorStub)1 OperationDefinition (graphql.language.OperationDefinition)1 Selection (graphql.language.Selection)1 SelectionSet (graphql.language.SelectionSet)1