Skip to content

Commit f2ffcc5

Browse files
committed
add more test cases for unions implementing interfaces
1 parent 1251538 commit f2ffcc5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/execution/__tests__/union-interface-test.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const CatType: GraphQLObjectType = new GraphQLObjectType({
110110

111111
const PetType = new GraphQLUnionType({
112112
name: 'Pet',
113+
interfaces: [MammalType, LifeType, NamedType],
113114
types: [DogType, CatType],
114115
resolveType(value) {
115116
if (value instanceof Dog) {
@@ -212,7 +213,7 @@ describe('Execute: Union and intersection types', () => {
212213
kind: 'UNION',
213214
name: 'Pet',
214215
fields: null,
215-
interfaces: [],
216+
interfaces: [{ name: 'Mammal' }, { name: 'Life' }, { name: 'Named' }],
216217
possibleTypes: [{ name: 'Dog' }, { name: 'Cat' }],
217218
enumValues: null,
218219
inputFields: null,
@@ -264,12 +265,11 @@ describe('Execute: Union and intersection types', () => {
264265
name
265266
pets {
266267
__typename
268+
name
267269
... on Dog {
268-
name
269270
barks
270271
}
271272
... on Cat {
272-
name
273273
meows
274274
}
275275
}
@@ -436,12 +436,11 @@ describe('Execute: Union and intersection types', () => {
436436
437437
fragment PetFields on Pet {
438438
__typename
439+
name
439440
... on Dog {
440-
name
441441
barks
442442
}
443443
... on Cat {
444-
name
445444
meows
446445
}
447446
}

src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ describe('Validate: Possible fragment spreads', () => {
121121
`);
122122
});
123123

124+
it('interface into implemented union', () => {
125+
expectValid(`
126+
fragment interfaceWithinUnion on DogOrCat { ...petFragment }
127+
fragment petFragment on Pet { name }
128+
`);
129+
});
130+
124131
it('interface into overlapping interface', () => {
125132
expectValid(`
126133
fragment interfaceWithinInterface on Pet { ...beingFragment }

0 commit comments

Comments
 (0)