@@ -13,6 +13,7 @@ import { TypeWeightObject, Variables } from '../../src/@types/buildTypeWeights';
1313 droid(id: ID!): Droid
1414 human(id: ID!): Human
1515 scalars: Scalars
16+ nonNull: [Droid!]!
1617 }
1718
1819 enum Episode {
@@ -100,6 +101,7 @@ import { TypeWeightObject, Variables } from '../../src/@types/buildTypeWeights';
100101const mockWeightFunction = jest . fn ( ) ;
101102const mockHumanFriendsFunction = jest . fn ( ) ;
102103const mockDroidFriendsFunction = jest . fn ( ) ;
104+ const nonNullMockWeightFunction = jest . fn ( ) ;
103105
104106// this object is created by the schema above for use in all the tests below
105107const typeWeights : TypeWeightObject = {
@@ -114,6 +116,7 @@ const typeWeights: TypeWeightObject = {
114116 droid : 1 ,
115117 human : 1 ,
116118 scalars : 1 ,
119+ nonNull : nonNullMockWeightFunction ,
117120 } ,
118121 } ,
119122 episode : {
@@ -295,6 +298,14 @@ describe('Test getQueryTypeComplexity function', () => {
295298 expect ( mockWeightFunction . mock . calls [ 1 ] . length ) . toBe ( 1 ) ;
296299 } ) ;
297300
301+ test ( 'with bounded lists including non-null operators' , ( ) => {
302+ query = `query {nonNull(episode: EMPIRE, first: 3) { stars, commentary } }` ;
303+ nonNullMockWeightFunction . mockReturnValueOnce ( 3 ) ;
304+ expect ( getQueryTypeComplexity ( parse ( query ) , { } , typeWeights ) ) . toBe ( 4 ) ; // 1 Query + 3 reviews
305+ expect ( nonNullMockWeightFunction . mock . calls . length ) . toBe ( 1 ) ;
306+ expect ( nonNullMockWeightFunction . mock . calls [ 0 ] . length ) . toBe ( 1 ) ;
307+ } ) ;
308+
298309 xdescribe ( 'with nested lists' , ( ) => {
299310 test ( 'and simple nesting' , ( ) => {
300311 query = `
0 commit comments