Search in sources :

Example 1 with FragmentSpread

use of graphql.language.FragmentSpread 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)

Example 2 with FragmentSpread

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

the class GraphqlAntlrToLanguage method visitFragmentSpread.

@Override
public Void visitFragmentSpread(GraphqlParser.FragmentSpreadContext ctx) {
    FragmentSpread fragmentSpread = new FragmentSpread(ctx.fragmentName().getText());
    newNode(fragmentSpread, ctx);
    ((SelectionSet) getFromContextStack(ContextProperty.SelectionSet)).getSelections().add(fragmentSpread);
    addContextProperty(ContextProperty.FragmentSpread, fragmentSpread);
    super.visitFragmentSpread(ctx);
    popContext();
    return null;
}
Also used : FragmentSpread(graphql.language.FragmentSpread)

Aggregations

FragmentSpread (graphql.language.FragmentSpread)2 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