@@ -149,6 +149,49 @@ describe('Compatibility Plugin', () => {
149
149
` ) ;
150
150
151
151
describe ( 'Issues' , ( ) => {
152
+ it ( 'Issue #1943 - Missing DiscriminateUnion on interface types with strict mode' , async ( ) => {
153
+ const testSchema = buildSchema ( /* GraphQL */ `
154
+ interface Book {
155
+ title: String
156
+ author: String
157
+ }
158
+
159
+ type TextBook implements Book {
160
+ title: String
161
+ author: String
162
+ classes: [String]
163
+ }
164
+
165
+ type ColoringBook implements Book {
166
+ title: String
167
+ author: String
168
+ colors: [String]
169
+ }
170
+
171
+ type Query {
172
+ schoolBooks: [Book]
173
+ }
174
+ ` ) ;
175
+ const testQuery = parse ( /* GraphQL */ `
176
+ query GetBooks {
177
+ schoolBooks {
178
+ title
179
+ ... on TextBook {
180
+ classes
181
+ }
182
+ ... on ColoringBook {
183
+ colors
184
+ }
185
+ }
186
+ }
187
+ ` ) ;
188
+
189
+ const operations = [ { filePath : '' , content : testQuery } ] ;
190
+ const config = { strict : true , noNamespaces : true } ;
191
+ const result = await plugin ( testSchema , operations , config ) ;
192
+
193
+ await validateAndCompile ( result , testSchema , operations , config , false ) ;
194
+ } ) ;
152
195
it ( 'Issue #1686 - Inline fragments on a union' , async ( ) => {
153
196
const testSchema = buildSchema ( /* GraphQL */ `
154
197
schema {
@@ -468,7 +511,7 @@ describe('Compatibility Plugin', () => {
468
511
469
512
expect ( result ) . toContain ( `export type Query = Me4Query;` ) ;
470
513
expect ( result ) . toContain ( `export type Me = Me4Query['me'];` ) ;
471
- validateAndCompile ( result , testSchema , ast ) ;
514
+ await validateAndCompile ( result , testSchema , ast ) ;
472
515
} ) ;
473
516
474
517
it ( 'Should work with interfaces and inline fragments' , async ( ) => {
@@ -511,7 +554,7 @@ describe('Compatibility Plugin', () => {
511
554
} ,
512
555
] ;
513
556
const result = await plugin ( testSchema , ast , { } ) ;
514
- validateAndCompile ( result , testSchema , ast ) ;
557
+ await validateAndCompile ( result , testSchema , ast ) ;
515
558
} ) ;
516
559
517
560
it ( 'Should generate namepsace and the internal types correctly' , async ( ) => {
@@ -557,7 +600,7 @@ describe('Compatibility Plugin', () => {
557
600
expect ( result ) . toContain ( `export type Friends = MeQuery['me']['friends'][0];` ) ;
558
601
expect ( result ) . toContain ( `export type _Friends = MeQuery['me']['friends'][0]['friends'][0];` ) ;
559
602
expect ( result ) . toContain ( `export type __Friends = MeQuery['me']['friends'][0]['friends'][0]['friends'][0];` ) ;
560
- validateAndCompile ( result , schema , ast ) ;
603
+ await validateAndCompile ( result , schema , ast ) ;
561
604
} ) ;
562
605
563
606
it ( 'Should work with fragment spread' , async ( ) => {
0 commit comments