@@ -5,7 +5,7 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
55
66import { GraphQLError } from '../../error/GraphQLError' ;
77
8- import type { DirectiveNode } from '../../language/ast' ;
8+ import type { DirectiveNode , StringValueNode } from '../../language/ast' ;
99import { parse } from '../../language/parser' ;
1010
1111import { buildSchema } from '../../utilities/buildASTSchema' ;
@@ -186,18 +186,44 @@ describe('operation and variable definition descriptions', () => {
186186 'type Query { field(a: Int, b: String): String }' ,
187187 ) ;
188188 const query = `
189- "Operation description"
190- query myQuery(
191- "Variable a description"
192- $a: Int,
193- """Variable b\nmultiline description"""
194- $b: String
195- ) {
196- field(a: $a, b: $b)
197- }
198- ` ;
189+ "Operation description"
190+ query myQuery(
191+ "Variable a description"
192+ $a: Int,
193+ """Variable b\nmultiline description"""
194+ $b: String
195+ ) {
196+ field(a: $a, b: $b)
197+ }
198+ ` ;
199199 const ast = parse ( query ) ;
200200 const errors = validate ( schema , ast ) ;
201201 expect ( errors . length ) . to . equal ( 0 ) ;
202202 } ) ;
203+
204+ it ( 'does not visit description nodes when validating executable documents' , ( ) => {
205+ const schema = buildSchema (
206+ 'type Query { field(a: Int, b: String): String }' ,
207+ ) ;
208+ const query = `
209+ """Operation description"""
210+ query myQuery(
211+ """Variable description"""
212+ $a: Int
213+ ) {
214+ field(a: $a, b: "literal value")
215+ }
216+ ` ;
217+ const seenStringLiterals : Array < string > = [ ] ;
218+ function trackingRule ( ) {
219+ return {
220+ StringValue ( node : StringValueNode ) {
221+ seenStringLiterals . push ( node . value ) ;
222+ } ,
223+ } ;
224+ }
225+ const errors = validate ( schema , parse ( query ) , [ trackingRule ] ) ;
226+ expect ( errors . length ) . to . equal ( 0 ) ;
227+ expect ( seenStringLiterals ) . to . deep . equal ( [ 'literal value' ] ) ;
228+ } ) ;
203229} ) ;
0 commit comments