11import { devAssert } from '../jsutils/devAssert' ;
2+ import { mapValue } from '../jsutils/mapValue' ;
23import type { Maybe } from '../jsutils/Maybe' ;
34
45import { GraphQLError } from '../error/GraphQLError' ;
56
6- import type { DocumentNode } from '../language/ast' ;
7+ import { type DocumentNode , QueryDocumentKeys } from '../language/ast' ;
78import { visit , visitInParallel } from '../language/visitor' ;
89
910import type { GraphQLSchema } from '../type/schema' ;
@@ -15,6 +16,13 @@ import { specifiedRules, specifiedSDLRules } from './specifiedRules';
1516import type { SDLValidationRule , ValidationRule } from './ValidationContext' ;
1617import { SDLValidationContext , ValidationContext } from './ValidationContext' ;
1718
19+ // Per the specification, descriptions must not affect validation.
20+ // See https://spec.graphql.org/draft/#sec-Descriptions
21+ const QueryDocumentKeysToValidate = mapValue (
22+ QueryDocumentKeys ,
23+ ( keys : ReadonlyArray < string > ) => keys . filter ( ( key ) => key !== 'description' ) ,
24+ ) ;
25+
1826/**
1927 * Implements the "Validation" section of the spec.
2028 *
@@ -76,7 +84,11 @@ export function validate(
7684
7785 // Visit the whole document with each instance of all provided rules.
7886 try {
79- visit ( documentAST , visitWithTypeInfo ( typeInfo , visitor ) ) ;
87+ visit (
88+ documentAST ,
89+ visitWithTypeInfo ( typeInfo , visitor ) ,
90+ QueryDocumentKeysToValidate ,
91+ ) ;
8092 } catch ( e ) {
8193 if ( e !== abortObj ) {
8294 throw e ;
0 commit comments