File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
packages/plugins/max-depth/test Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -269,4 +269,39 @@ describe('maxDepthPlugin', () => {
269
269
`Syntax Error: Query depth limit of ${ maxDepth } exceeded, found ${ maxDepth + 2 } .` ,
270
270
] ) ;
271
271
} ) ;
272
+
273
+ it ( 'rejects for exceeding max depth by reusing a cached Fragment' , async ( ) => {
274
+ const bypass_query = `
275
+ query {
276
+ books {
277
+ author {
278
+ ...Test
279
+ }
280
+ }
281
+ books {
282
+ author {
283
+ books {
284
+ author {
285
+ ...Test
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ fragment Test on Author {
292
+ books {
293
+ title
294
+ }
295
+ }
296
+ ` ;
297
+ const maxDepth = 6 ;
298
+ const testkit = createTestkit ( [ maxDepthPlugin ( { n : maxDepth , exposeLimits : true } ) ] , schema ) ;
299
+ const result = await testkit . execute ( bypass_query ) ;
300
+
301
+ assertSingleExecutionValue ( result ) ;
302
+ expect ( result . errors ) . toBeDefined ( ) ;
303
+ expect ( result . errors ?. map ( ( error ) => error . message ) ) . toEqual ( [
304
+ `Syntax Error: Query depth limit of ${ maxDepth } exceeded, found ${ maxDepth + 2 } .` ,
305
+ ] ) ;
306
+ } ) ;
272
307
} ) ;
You can’t perform that action at this time.
0 commit comments