Skip to content

Commit 688a1ee

Browse files
committed
Validation: context.getFragmentSpreads now accepts selectionSet rather than fragment AST node
1 parent cf9be87 commit 688a1ee

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/validation/rules/NoFragmentCycles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function NoFragmentCycles(context: ValidationContext): any {
4949
const fragmentName = fragment.name.value;
5050
visitedFrags[fragmentName] = true;
5151

52-
const spreadNodes = context.getFragmentSpreads(fragment);
52+
const spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
5353
if (spreadNodes.length === 0) {
5454
return;
5555
}

src/validation/validate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class ValidationContext {
9595
_typeInfo: TypeInfo;
9696
_errors: Array<GraphQLError>;
9797
_fragments: {[name: string]: FragmentDefinition};
98-
_fragmentSpreads: Map<HasSelectionSet, Array<FragmentSpread>>;
98+
_fragmentSpreads: Map<SelectionSet, Array<FragmentSpread>>;
9999
_recursivelyReferencedFragments:
100100
Map<OperationDefinition, Array<FragmentDefinition>>;
101101
_variableUsages: Map<HasSelectionSet, Array<VariableUsage>>;
@@ -142,11 +142,11 @@ export class ValidationContext {
142142
return fragments[name];
143143
}
144144

145-
getFragmentSpreads(node: HasSelectionSet): Array<FragmentSpread> {
145+
getFragmentSpreads(node: SelectionSet): Array<FragmentSpread> {
146146
let spreads = this._fragmentSpreads.get(node);
147147
if (!spreads) {
148148
spreads = [];
149-
const setsToVisit: Array<SelectionSet> = [ node.selectionSet ];
149+
const setsToVisit: Array<SelectionSet> = [ node ];
150150
while (setsToVisit.length !== 0) {
151151
const set = setsToVisit.pop();
152152
for (let i = 0; i < set.selections.length; i++) {
@@ -170,7 +170,7 @@ export class ValidationContext {
170170
if (!fragments) {
171171
fragments = [];
172172
const collectedNames = Object.create(null);
173-
const nodesToVisit: Array<HasSelectionSet> = [ operation ];
173+
const nodesToVisit: Array<SelectionSet> = [ operation.selectionSet ];
174174
while (nodesToVisit.length !== 0) {
175175
const node = nodesToVisit.pop();
176176
const spreads = this.getFragmentSpreads(node);
@@ -181,7 +181,7 @@ export class ValidationContext {
181181
const fragment = this.getFragment(fragName);
182182
if (fragment) {
183183
fragments.push(fragment);
184-
nodesToVisit.push(fragment);
184+
nodesToVisit.push(fragment.selectionSet);
185185
}
186186
}
187187
}

0 commit comments

Comments
 (0)