@@ -580,6 +580,14 @@ describe(`NodeModel`, () => {
580
580
contentDigest : `1` ,
581
581
} ,
582
582
} ,
583
+ // Test2 is a special type that must have no nodes!
584
+ {
585
+ id : `id3` ,
586
+ internal : {
587
+ type : `Test3` ,
588
+ contentDigest : `2` ,
589
+ } ,
590
+ } ,
583
591
] ) ( )
584
592
store . dispatch ( { type : `DELETE_CACHE` } )
585
593
nodes . forEach ( node =>
@@ -590,6 +598,13 @@ describe(`NodeModel`, () => {
590
598
store . dispatch ( {
591
599
type : `CREATE_TYPES` ,
592
600
payload : [
601
+ typeBuilders . buildInterfaceType ( {
602
+ name : `TestInterface` ,
603
+ fields : {
604
+ slug : { type : `String` } ,
605
+ } ,
606
+ } ) ,
607
+
593
608
typeBuilders . buildInterfaceType ( {
594
609
name : `TestNestedInterface` ,
595
610
fields : {
@@ -609,7 +624,7 @@ describe(`NodeModel`, () => {
609
624
610
625
typeBuilders . buildObjectType ( {
611
626
name : `Test` ,
612
- interfaces : [ `Node` ] ,
627
+ interfaces : [ `Node` , `TestInterface` ] ,
613
628
fields : {
614
629
betterTitle : {
615
630
type : `String` ,
@@ -641,6 +656,30 @@ describe(`NodeModel`, () => {
641
656
undefined ,
642
657
] ,
643
658
} ,
659
+ slug : {
660
+ type : `String` ,
661
+ resolve : source => source . id ,
662
+ } ,
663
+ } ,
664
+ } ) ,
665
+ typeBuilders . buildObjectType ( {
666
+ name : `Test2` ,
667
+ interfaces : [ `Node` , `TestInterface` ] ,
668
+ fields : {
669
+ slug : {
670
+ type : `String` ,
671
+ resolve : source => source . id ,
672
+ } ,
673
+ } ,
674
+ } ) ,
675
+ typeBuilders . buildObjectType ( {
676
+ name : `Test3` ,
677
+ interfaces : [ `Node` , `TestInterface` ] ,
678
+ fields : {
679
+ slug : {
680
+ type : `String` ,
681
+ resolve : source => source . id ,
682
+ } ,
644
683
} ,
645
684
} ) ,
646
685
] ,
@@ -789,6 +828,22 @@ describe(`NodeModel`, () => {
789
828
expect ( result . length ) . toEqual ( 1 )
790
829
expect ( result [ 0 ] . id ) . toEqual ( `id1` )
791
830
} )
831
+
832
+ it ( `handles fields with custom resolvers on interfaces having multiple implementations` , async ( ) => {
833
+ nodeModel . replaceFiltersCache ( )
834
+ const result = await nodeModel . runQuery (
835
+ {
836
+ query : {
837
+ filter : { slug : { eq : `id3` } } ,
838
+ } ,
839
+ firstOnly : true ,
840
+ type : `TestInterface` ,
841
+ } ,
842
+ { path : `/` }
843
+ )
844
+ expect ( result ) . toBeTruthy ( )
845
+ expect ( result . id ) . toEqual ( `id3` )
846
+ } )
792
847
} )
793
848
794
849
describe ( `node tracking` , ( ) => {
0 commit comments