private Builder(InlineFragment existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.typeCondition = existing.getTypeCondition(); this.directives = existing.getDirectives(); this.selectionSet = existing.getSelectionSet(); this.ignoredChars = existing.getIgnoredChars(); }
private void collectInlineFragment(FieldCollectorParameters parameters, List<String> visitedFragments, Map<String, MergedField> fields, InlineFragment inlineFragment) { if (!conditionalNodes.shouldInclude(parameters.getVariables(), inlineFragment.getDirectives()) || !doesFragmentConditionMatch(parameters, inlineFragment)) { return; } collectFields(parameters, inlineFragment.getSelectionSet(), visitedFragments, fields); }
@Override public TraversalControl visitInlineFragment(InlineFragment node, TraverserContext<Node> context) { InlineFragment changedNode = node.transform(builder -> { builder.directives(sort(node.getDirectives(), comparing(Directive::getName))); builder.selectionSet(sortSelectionSet(node.getSelectionSet())); }); return changeNode(context, changedNode); }
private NodePrinter<InlineFragment> inlineFragment() { return (out, node) -> { TypeName typeName = node.getTypeCondition(); //Inline fragments may not have a type condition String typeCondition = typeName == null ? "" : wrap("on ", type(typeName), ""); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("%s", comments(node)); out.printf("%s", spaced( "...", typeCondition, directives, selectionSet )); }; }
private void collectFieldsForInlineFragment(Map<String, List<FieldAndType>> fieldMap, Set<String> visitedFragmentSpreads, GraphQLType parentType, InlineFragment inlineFragment) { GraphQLType graphQLType = inlineFragment.getTypeCondition() != null ? (GraphQLOutputType) TypeFromAST.getTypeFromAST(getValidationContext().getSchema(), inlineFragment.getTypeCondition()) : parentType; collectFields(fieldMap, inlineFragment.getSelectionSet(), graphQLType, visitedFragmentSpreads); }
@Override public void visitInlineFragment(QueryVisitorInlineFragmentEnvironment env) { InlineFragment fragment = env.getInlineFragment(); boolean containsField = fieldsToFind.stream().anyMatch(field -> fragment.getSelectionSet().getSelections().contains(field)); boolean isRelevant = containsField || relevantFragments.stream().anyMatch(frag -> fragment.getSelectionSet().getSelections().contains(frag)); if (isRelevant) { relevantFragments.add(fragment); inlineFragmentDirs.addAll(fragment.getDirectives()); } }
private Builder(InlineFragment existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.typeCondition = existing.getTypeCondition(); this.directives = existing.getDirectives(); this.selectionSet = existing.getSelectionSet(); this.ignoredChars = existing.getIgnoredChars(); }
@Override public TraversalControl visitInlineFragment(InlineFragment node, TraverserContext<Node> context) { InlineFragment changedNode = node.transform(builder -> { builder.directives(sort(node.getDirectives(), comparing(Directive::getName))); builder.selectionSet(sortSelectionSet(node.getSelectionSet())); }); return changeNode(context, changedNode); }
private void collectInlineFragment(FieldCollectorParameters parameters, List<String> visitedFragments, Map<String, MergedField> fields, InlineFragment inlineFragment) { if (!conditionalNodes.shouldInclude(parameters.getVariables(), inlineFragment.getDirectives()) || !doesFragmentConditionMatch(parameters, inlineFragment)) { return; } collectFields(parameters, inlineFragment.getSelectionSet(), visitedFragments, fields); }
private NodePrinter<InlineFragment> inlineFragment() { return (out, node) -> { TypeName typeName = node.getTypeCondition(); //Inline fragments may not have a type condition String typeCondition = typeName == null ? "" : wrap("on ", type(typeName), ""); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("%s", comments(node)); out.printf("%s", spaced( "...", typeCondition, directives, selectionSet )); }; }
private void collectFieldsForInlineFragment(Map<String, List<FieldAndType>> fieldMap, Set<String> visitedFragmentSpreads, GraphQLType parentType, InlineFragment inlineFragment) { GraphQLType graphQLType = inlineFragment.getTypeCondition() != null ? (GraphQLOutputType) TypeFromAST.getTypeFromAST(getValidationContext().getSchema(), inlineFragment.getTypeCondition()) : parentType; collectFields(fieldMap, inlineFragment.getSelectionSet(), graphQLType, visitedFragmentSpreads); }
private void collectInlineFragment(FieldCollectorParameters parameters, Map<String, List<ResolvedField>> fields, List<String> visitedFragments, InlineFragment inlineFragment, GraphQLFieldsContainer parent) { if (!conditionalNodes.shouldInclude(parameters.getVariables(), inlineFragment.getDirectives())) { return; } if (inlineFragment.getTypeCondition() != null) { parent = (GraphQLFieldsContainer) getTypeFromAST(parameters.getGraphQLSchema(), inlineFragment.getTypeCondition()); } collectFields(parameters, fields, inlineFragment.getSelectionSet().getSelections(), visitedFragments, parent); }