Skip to content

Commit 16fef9e

Browse files
ChaituVRbonustrack
andauthored
feat: default limit for all _in fields (#1048)
* feat: default limit for all _in fields ### Summary - added default limit for all *_in fields to ARG_LIMITS * Update src/graphql/helpers.ts Co-authored-by: Less <[email protected]> * Update src/graphql/helpers.ts --------- Co-authored-by: Less <[email protected]>
1 parent ca37721 commit 16fef9e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/graphql/helpers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export class PublicError extends Error {}
2121
const ARG_LIMITS = {
2222
default: {
2323
first: 1000,
24-
skip: 5000
24+
skip: 5000,
25+
'*_in': 100 // Default limit for all _in arguments
2526
},
2627
proposals: {
2728
space_in: 10000
@@ -53,6 +54,13 @@ export function checkLimits(args: any = {}, type) {
5354
const { where = {} } = args;
5455
const typeLimits = { ...ARG_LIMITS.default, ...(ARG_LIMITS[type] || {}) };
5556

57+
// overwrite default limit for all *_in or *_not_in fields
58+
Object.keys(where).forEach(key => {
59+
if (key.endsWith('_in') && !(key in typeLimits)) {
60+
typeLimits[key] = typeLimits['*_in'];
61+
}
62+
});
63+
5664
for (const key in typeLimits) {
5765
const limit = typeLimits[key];
5866
const firstLimitReached = key === 'first' && args[key] > limit;

0 commit comments

Comments
 (0)