Skip to content

Commit

Permalink
Revert "fix: empty array in graphql filters should trigger an error (#…
Browse files Browse the repository at this point in the history
…763)" (#764)

This reverts commit c2d4fd5.
  • Loading branch information
ChaituVR authored Nov 29, 2023
1 parent c2d4fd5 commit 1db7b01
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/graphql/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,12 @@ export function checkLimits(args: any = {}, type) {
const skipLimitReached = key === 'skip' && args[key] > limit;
const whereLimitReached = key.endsWith('_in') ? where[key]?.length > limit : where[key] > limit;
if (firstLimitReached || skipLimitReached || whereLimitReached)
throw new PublicError(`The \`${key}\` argument must not be greater than ${limit}`);
throw new Error(`The \`${key}\` argument must not be greater than ${limit}`);

if (['first', 'skip'].includes(key) && args[key] < 0) {
throw new PublicError(`The \`${key}\` argument must be positive`);
throw new Error(`The \`${key}\` argument must be positive`);
}
}

Object.keys(where).forEach(key => {
if (key.endsWith('_in') && where[key].length === 0) {
throw new PublicError(`${key} must have at least one item`);
}
});

return true;
}

Expand Down

0 comments on commit 1db7b01

Please sign in to comment.