Skip to content

Commit 439a3e2

Browse files
committed
Merge pull request #237 from graphql/no-visitSpreadFragments
[Validation] Remove visitFragmentSpreads
2 parents 320ca24 + c73cc72 commit 439a3e2

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

src/validation/validate.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ import { specifiedRules } from './specifiedRules';
4545
* Each validation rules is a function which returns a visitor
4646
* (see the language/visitor API). Visitor methods are expected to return
4747
* GraphQLErrors, or Arrays of GraphQLErrors when invalid.
48-
*
49-
* Visitors can also supply `visitSpreadFragments: true` which will alter the
50-
* behavior of the visitor to skip over top level defined fragments, and instead
51-
* visit those fragments at every point a spread is encountered.
5248
*/
5349
export function validate(
5450
schema: GraphQLSchema,
@@ -82,38 +78,14 @@ export function visitUsingRules(
8278

8379
function visitInstance(ast, instance) {
8480
visit(ast, {
85-
enter(node, key) {
81+
enter(node) {
8682
// Collect type information about the current position in the AST.
8783
typeInfo.enter(node);
8884

89-
// Do not visit top level fragment definitions if this instance will
90-
// visit those fragments inline because it
91-
// provided `visitSpreadFragments`.
92-
var result;
93-
if (
94-
node.kind === Kind.FRAGMENT_DEFINITION &&
95-
key !== undefined &&
96-
instance.visitSpreadFragments
97-
) {
98-
return false;
99-
}
100-
10185
// Get the visitor function from the validation instance, and if it
10286
// exists, call it with the visitor arguments.
10387
var enter = getVisitFn(instance, false, node.kind);
104-
result = enter ? enter.apply(instance, arguments) : undefined;
105-
106-
// If any validation instances provide the flag `visitSpreadFragments`
107-
// and this node is a fragment spread, visit the fragment definition
108-
// from this point.
109-
if (result === undefined &&
110-
instance.visitSpreadFragments &&
111-
node.kind === Kind.FRAGMENT_SPREAD) {
112-
var fragment = context.getFragment(node.name.value);
113-
if (fragment) {
114-
visitInstance(fragment, instance);
115-
}
116-
}
88+
var result = enter ? enter.apply(instance, arguments) : undefined;
11789

11890
// If the result is "false", we're not visiting any descendent nodes,
11991
// but need to update typeInfo.

0 commit comments

Comments
 (0)