diff --git a/src/type/__tests__/validation-test.ts b/src/type/__tests__/validation-test.ts index f8c31d3184..a5bd4012fe 100644 --- a/src/type/__tests__/validation-test.ts +++ b/src/type/__tests__/validation-test.ts @@ -3215,6 +3215,29 @@ describe('Objects must adhere to Interface they implement', () => { expectJSON(validateSchema(schema)).toDeepEqual([]); }); + it('accepts an Object with a subset non-null Interface field type (union)', () => { + const schema = buildSchema(` + type Query { + test: AnotherObject + } + + type SomeObject { + field: String + } + + union SomeUnionType = SomeObject + + interface AnotherInterface { + field: SomeUnionType + } + + type AnotherObject implements AnotherInterface { + field: SomeUnionType! + } + `); + expectJSON(validateSchema(schema)).toDeepEqual([]); + }); + it('rejects an Object with a superset nullable Interface field type', () => { const schema = buildSchema(` type Query { @@ -3672,6 +3695,29 @@ describe('Interfaces must adhere to Interface they implement', () => { expectJSON(validateSchema(schema)).toDeepEqual([]); }); + it('accepts an Interface with a subset non-null Interface field type (union)', () => { + const schema = buildSchema(` + type Query { + test: ChildInterface + } + + type SomeObject { + field: String + } + + union SomeUnionType = SomeObject + + interface ParentInterface { + field: SomeUnionType + } + + interface ChildInterface implements ParentInterface { + field: SomeUnionType! + } + `); + expectJSON(validateSchema(schema)).toDeepEqual([]); + }); + it('rejects an Interface with a superset nullable Interface field type', () => { const schema = buildSchema(` type Query {