File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,6 @@ describe('findMany() ->', () => {
187187 }` ,
188188 } ) ;
189189 expect ( res ) . toEqual ( [ { name : 'userName1' } , { name : 'userName2' } ] ) ;
190- expect ( spyQuery ?. options ) . toEqual ( { limit : 1000 , sort : { _id : 1 , name : 1 } } ) ;
190+ expect ( spyQuery ?. options ) . toEqual ( { limit : 100 , sort : { _id : 1 , name : 1 } } ) ;
191191 } ) ;
192192} ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ describe('Resolver helper `limit` ->', () => {
77 expect ( args . limit . type ) . toBe ( 'Int' ) ;
88 } ) ;
99 it ( 'should process `opts.defaultValue` arg' , ( ) => {
10- expect ( ( limitHelperArgs ( ) as any ) . limit . defaultValue ) . toBe ( 1000 ) ;
10+ expect ( ( limitHelperArgs ( ) as any ) . limit . defaultValue ) . toBe ( 100 ) ;
1111 expect (
1212 ( limitHelperArgs ( {
1313 defaultValue : 333 ,
Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ import type { ObjectTypeComposerArgumentConfigMapDefinition } from 'graphql-comp
22import type { ExtendedResolveParams } from '../index' ;
33
44export type LimitHelperArgsOpts = {
5+ /**
6+ * Set limit for default number of returned records
7+ * if it does not provided in query.
8+ * By default: 100
9+ */
510 defaultValue ?: number ;
611} ;
712
@@ -14,13 +19,13 @@ export function limitHelperArgs(
1419 return {
1520 limit : {
1621 type : 'Int' ,
17- defaultValue : ( opts && opts . defaultValue ) || 1000 ,
22+ defaultValue : opts ? .defaultValue || 100 ,
1823 } ,
1924 } ;
2025}
2126
2227export function limitHelper ( resolveParams : ExtendedResolveParams ) : void {
23- const limit = parseInt ( resolveParams . args && resolveParams . args . limit , 10 ) || 0 ;
28+ const limit = parseInt ( resolveParams . args ? .limit , 10 ) || 0 ;
2429 if ( limit > 0 ) {
2530 resolveParams . query = resolveParams . query . limit ( limit ) ;
2631 }
You can’t perform that action at this time.
0 commit comments