Skip to content

Commit bdad1aa

Browse files
committed
chore: rebase
1 parent 07e0e96 commit bdad1aa

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

packages/plugins/max-depth/test/index.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,39 @@ describe('maxDepthPlugin', () => {
269269
`Syntax Error: Query depth limit of ${maxDepth} exceeded, found ${maxDepth + 2}.`,
270270
]);
271271
});
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+
});
272307
});

0 commit comments

Comments
 (0)