Skip to content

Commit 489a024

Browse files
committed
fix: skip fragment computation when limits already exceeded
1 parent 36fa3f8 commit 489a024

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/GraphQL/helpers/queryComplexity.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ function calculateQueryComplexity(operation, fragments, limits = {}) {
4545
}
4646
const fragment = fragments[name];
4747
if (fragment) {
48+
if (
49+
(allowedMaxFields !== undefined && allowedMaxFields !== -1 && totalFields > allowedMaxFields) ||
50+
(allowedMaxDepth !== undefined && allowedMaxDepth !== -1 && maxDepth > allowedMaxDepth)
51+
) {
52+
continue;
53+
}
4854
visitedFragments.add(name);
4955
const savedFields = totalFields;
5056
const savedMaxDepth = maxDepth;

0 commit comments

Comments
 (0)