Class AstTransformer

java.lang.Object
graphql.language.AstTransformer

@PublicApi public class AstTransformer extends Object
Allows for an easy way to "manipulate" the immutable Ast by changing specific nodes and getting back a new Ast containing the changed nodes while everything else is the same.
  • Constructor Details

    • AstTransformer

      public AstTransformer()
  • Method Details

    • transform

      public Node transform(Node root, NodeVisitor nodeVisitor)
      Transforms the input tree using the Visitor Pattern.
      Parameters:
      root - the root node of the input tree.
      nodeVisitor - the visitor which will transform the input tree.
      Returns:
      the transformed tree.
    • transform

      public Node transform(Node root, NodeVisitor nodeVisitor, Map<Class<?>,Object> rootVars)
      Transforms the input tree using the Visitor Pattern.
      Parameters:
      root - the root node of the input tree.
      nodeVisitor - the visitor which will transform the input tree.
      rootVars - a context argument to pass information into the nodeVisitor. Pass a contextual object to your visitor by adding it to this map such that such that the key is the class of the object, and the value is the object itself. The object can be retrieved within the visitor by calling context.getVarFromParents().
      Returns:
      the transformed tree.
    • transformParallel

      public Node transformParallel(Node root, NodeVisitor nodeVisitor)
    • transformParallel

      public Node transformParallel(Node root, NodeVisitor nodeVisitor, ForkJoinPool forkJoinPool)