@@ -242,6 +242,93 @@ describe('request complexity', () => {
242242 rest . find ( config , auth . nobody ( config ) , '_User' , where )
243243 ) . toBeResolved ( ) ;
244244 } ) ;
245+
246+ it ( 'should allow multiple sibling $inQuery at same depth within limit' , async ( ) => {
247+ await reconfigureServer ( {
248+ requestComplexity : { subqueryDepth : 1 } ,
249+ } ) ;
250+ config = Config . get ( 'test' ) ;
251+ // Multiple sibling $inQuery operators in $or, each at depth 1 — within the limit
252+ const where = {
253+ $or : [
254+ { username : { $inQuery : { className : '_User' , where : { username : 'a' } } } } ,
255+ { username : { $inQuery : { className : '_User' , where : { username : 'b' } } } } ,
256+ { username : { $inQuery : { className : '_User' , where : { username : 'c' } } } } ,
257+ ] ,
258+ } ;
259+ await expectAsync (
260+ rest . find ( config , auth . nobody ( config ) , '_User' , where )
261+ ) . toBeResolved ( ) ;
262+ } ) ;
263+
264+ it ( 'should reject sibling $inQuery when nested beyond depth limit' , async ( ) => {
265+ await reconfigureServer ( {
266+ requestComplexity : { subqueryDepth : 1 } ,
267+ } ) ;
268+ config = Config . get ( 'test' ) ;
269+ // Each sibling contains a nested $inQuery at depth 2 — exceeds limit
270+ const where = {
271+ $or : [
272+ {
273+ username : {
274+ $inQuery : {
275+ className : '_User' ,
276+ where : { username : { $inQuery : { className : '_User' , where : { } } } } ,
277+ } ,
278+ } ,
279+ } ,
280+ {
281+ username : {
282+ $inQuery : {
283+ className : '_User' ,
284+ where : { username : { $inQuery : { className : '_User' , where : { } } } } ,
285+ } ,
286+ } ,
287+ } ,
288+ ] ,
289+ } ;
290+ await expectAsync (
291+ rest . find ( config , auth . nobody ( config ) , '_User' , where )
292+ ) . toBeRejectedWith (
293+ jasmine . objectContaining ( {
294+ message : jasmine . stringMatching ( / S u b q u e r y n e s t i n g d e p t h e x c e e d s m a x i m u m a l l o w e d d e p t h o f 1 / ) ,
295+ } )
296+ ) ;
297+ } ) ;
298+
299+ it ( 'should allow multiple sibling $notInQuery at same depth within limit' , async ( ) => {
300+ await reconfigureServer ( {
301+ requestComplexity : { subqueryDepth : 1 } ,
302+ } ) ;
303+ config = Config . get ( 'test' ) ;
304+ const where = {
305+ $or : [
306+ { username : { $notInQuery : { className : '_User' , where : { username : 'a' } } } } ,
307+ { username : { $notInQuery : { className : '_User' , where : { username : 'b' } } } } ,
308+ { username : { $notInQuery : { className : '_User' , where : { username : 'c' } } } } ,
309+ ] ,
310+ } ;
311+ await expectAsync (
312+ rest . find ( config , auth . nobody ( config ) , '_User' , where )
313+ ) . toBeResolved ( ) ;
314+ } ) ;
315+
316+ it ( 'should allow mixed sibling $inQuery and $notInQuery at same depth within limit' , async ( ) => {
317+ await reconfigureServer ( {
318+ requestComplexity : { subqueryDepth : 1 } ,
319+ } ) ;
320+ config = Config . get ( 'test' ) ;
321+ const where = {
322+ $or : [
323+ { username : { $inQuery : { className : '_User' , where : { username : 'a' } } } } ,
324+ { username : { $notInQuery : { className : '_User' , where : { username : 'b' } } } } ,
325+ { username : { $inQuery : { className : '_User' , where : { username : 'c' } } } } ,
326+ ] ,
327+ } ;
328+ await expectAsync (
329+ rest . find ( config , auth . nobody ( config ) , '_User' , where )
330+ ) . toBeResolved ( ) ;
331+ } ) ;
245332 } ) ;
246333
247334 describe ( 'query depth' , ( ) => {
0 commit comments