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;
}
Aggregations