@@ -37,6 +37,11 @@ const nodes = [
37
37
} ,
38
38
{
39
39
id : `id2` ,
40
+ internal : { type : `ArrayTest` } ,
41
+ array : [ { foo : true } ] ,
42
+ } ,
43
+ {
44
+ id : `id3` ,
40
45
internal : { type : `LinkTest` } ,
41
46
link___NODE : `id1` ,
42
47
links___NODE : [ `id1` ] ,
@@ -283,6 +288,40 @@ describe(`merges explicit and inferred type definitions`, () => {
283
288
expect ( fields . explicitDate . resolve ) . toBeUndefined ( )
284
289
} )
285
290
291
+ it ( `honors array depth when merging types` , async ( ) => {
292
+ const typeDefs = `
293
+ type FooBar {
294
+ bar: Boolean
295
+ }
296
+ type ArrayTest implements Node {
297
+ array: [FooBar]
298
+ }
299
+ `
300
+ store . dispatch ( { type : `CREATE_TYPES` , payload : typeDefs } )
301
+ await build ( { } )
302
+ const { schema } = store . getState ( )
303
+ const { foo, bar } = schema . getType ( `FooBar` ) . getFields ( )
304
+ expect ( foo . type . toString ( ) ) . toBe ( `Boolean` )
305
+ expect ( bar . type . toString ( ) ) . toBe ( `Boolean` )
306
+ } )
307
+
308
+ it ( `does not merge types when array depth does not match` , async ( ) => {
309
+ const typeDefs = `
310
+ type FooBar {
311
+ bar: Boolean
312
+ }
313
+ type ArrayTest implements Node {
314
+ array: FooBar
315
+ }
316
+ `
317
+ store . dispatch ( { type : `CREATE_TYPES` , payload : typeDefs } )
318
+ await build ( { } )
319
+ const { schema } = store . getState ( )
320
+ const { foo, bar } = schema . getType ( `FooBar` ) . getFields ( )
321
+ expect ( foo ) . toBeUndefined ( )
322
+ expect ( bar . type . toString ( ) ) . toBe ( `Boolean` )
323
+ } )
324
+
286
325
it ( `preserves foreign-key resolvers on ___NODE fields when noDefaultResolvers: false` , async ( ) => {
287
326
const typeDefs = `
288
327
type LinkTest implements Node {
0 commit comments