Package graphql.analysis
Class QueryTransformer
- java.lang.Object
-
- graphql.analysis.QueryTransformer
-
@PublicApi public class QueryTransformer extends java.lang.Object
Helps to transform a Document (or parts of it) and tracks at the same time the corresponding Schema types.This is an important distinction to just traversing the Document without any type information: Each field has a clearly defined type. See
QueryVisitorFieldEnvironment
.Furthermore are the built in Directives skip/include automatically evaluated: if parts of the Document should be ignored they will not be visited. But this is not a full evaluation of a Query: every fragment will be visited/followed regardless of the type condition.
It also doesn't consider field merging, which means for example
{ user{firstName} user{firstName}}
will result in four visitField calls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryTransformer.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static QueryTransformer.Builder
newQueryTransformer()
Node
transform(QueryVisitor queryVisitor)
Visits the Document in pre-order and allows to transform it usingTreeTransformerUtil
methods.
-
-
-
Method Detail
-
transform
public Node transform(QueryVisitor queryVisitor)
Visits the Document in pre-order and allows to transform it usingTreeTransformerUtil
methods. Please note that fragment spreads are not followed and need to be processed explicitly by supplying them as root.- Parameters:
queryVisitor
- the query visitor that will be called back.- Returns:
- changed root
- Throws:
java.lang.IllegalArgumentException
- if there are multiple root nodes.
-
newQueryTransformer
public static QueryTransformer.Builder newQueryTransformer()
-
-