@@ -17,6 +17,9 @@ var converter = require('../../index'),
17
17
invalidSchemaJson = require ( './fixtures/invalidSchema.json' ) ,
18
18
validSchemaSDL = fs . readFileSync ( path . join ( __dirname , './fixtures/validSchemaSDL.graphql' ) ) . toString ( ) ,
19
19
selfRefSchema = fs . readFileSync ( path . join ( __dirname , './fixtures/selfRefUnionTypeExample.graphql' ) ) . toString ( ) ,
20
+ seflRefDepthUnionSchema = fs . readFileSync (
21
+ path . join ( __dirname , './fixtures/seflRefDepthUnionSchema.graphql' )
22
+ ) . toString ( ) ,
20
23
customTypeNames = fs . readFileSync ( path . join ( __dirname , './fixtures/custom-queryname.gql' ) ) . toString ( ) ,
21
24
issue10 = fs . readFileSync ( path . join ( __dirname , './fixtures/issue#10.graphql' ) ) . toString ( ) ,
22
25
circularInput = fs . readFileSync ( path . join ( __dirname , './fixtures/circularInput.graphql' ) ) . toString ( ) ,
@@ -120,7 +123,7 @@ describe('Converter tests', function () {
120
123
it ( 'should generate a collection for a valid SDL schema with a union type self referencing' , function ( done ) {
121
124
convert ( { type : 'string' ,
122
125
data : selfRefSchema
123
- } , { } , function ( error , result ) {
126
+ } , { depth : 3 } , function ( error , result ) {
124
127
if ( error ) {
125
128
expect . fail ( null , null , error ) ;
126
129
return done ( ) ;
@@ -268,6 +271,28 @@ describe('Converter tests', function () {
268
271
return done ( ) ;
269
272
} ) ;
270
273
} ) ;
274
+
275
+ it ( 'should generate a collection for a valid SDL schema with a union type self referencing' +
276
+ ' and past allowed depth limit' , function ( done ) {
277
+ convert ( { type : 'string' ,
278
+ data : seflRefDepthUnionSchema
279
+ } , { depth : 3 } , function ( error , result ) {
280
+ if ( error ) {
281
+ expect . fail ( null , null , error ) ;
282
+ return done ( ) ;
283
+ }
284
+ const collection = result . output [ 0 ] . data ;
285
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . mode ) . to . be . equal ( 'graphql' ) ;
286
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql ) . to . be . an ( 'object' ) ;
287
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql . query ) . to . be . a ( 'string' ) ;
288
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql . variables ) . to . be . a ( 'string' ) ;
289
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql . query ) . to . contain ( '# self reference detected' ) ;
290
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql . query ) . to . contain ( '# skipping "createdBy"' ) ;
291
+ expect ( collection . item [ 0 ] . item [ 0 ] . request . body . graphql . query ) . to . contain ( '# skipping "updatedBy"' ) ;
292
+
293
+ return done ( ) ;
294
+ } ) ;
295
+ } ) ;
271
296
} ) ;
272
297
273
298
describe ( 'Validate function' , function ( ) {
0 commit comments