Search in sources :

Example 1 with DocumentVisitor

use of graphql.validation.DocumentVisitor in project graphql-java by graphql-java.

the class NoFragmentCycles method gatherSpreads.

private List<FragmentSpread> gatherSpreads(FragmentDefinition fragmentDefinition) {
    final List<FragmentSpread> fragmentSpreads = new ArrayList<>();
    DocumentVisitor visitor = new DocumentVisitor() {

        @Override
        public void enter(Node node, List<Node> path) {
            if (node instanceof FragmentSpread) {
                fragmentSpreads.add((FragmentSpread) node);
            }
        }

        @Override
        public void leave(Node node, List<Node> path) {
        }
    };
    new LanguageTraversal().traverse(fragmentDefinition, visitor);
    return fragmentSpreads;
}
Also used : DocumentVisitor(graphql.validation.DocumentVisitor) Node(graphql.language.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LanguageTraversal(graphql.validation.LanguageTraversal) FragmentSpread(graphql.language.FragmentSpread)

Aggregations

FragmentSpread (graphql.language.FragmentSpread)1 Node (graphql.language.Node)1 DocumentVisitor (graphql.validation.DocumentVisitor)1 LanguageTraversal (graphql.validation.LanguageTraversal)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1