Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/type/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down