Skip to content

Allow interfaces to have no implementors #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions src/type/__tests__/validation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ describe('Type System: Interface fields must have output types', () => {
]);
});

it('rejects an interface not implemented by at least one object', () => {
it('accepts an interface not implemented by at least one object', () => {
const schema = buildSchema(`
type Query {
test: SomeInterface
Expand All @@ -1215,13 +1215,7 @@ describe('Type System: Interface fields must have output types', () => {
foo: String
}
`);
expect(validateSchema(schema)).to.deep.equal([
{
message:
'Interface SomeInterface must be implemented by at least one Object type.',
locations: [{ line: 6, column: 7 }],
},
]);
expect(validateSchema(schema)).to.deep.equal([]);
});
});

Expand Down
18 changes: 0 additions & 18 deletions src/type/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ function validateTypes(context: SchemaValidationContext): void {
} else if (isInterfaceType(type)) {
// Ensure fields are valid.
validateFields(context, type);

// Ensure Interfaces include at least 1 Object type.
validateInterfaces(context, type);
} else if (isUnionType(type)) {
// Ensure Unions include valid member types.
validateUnionMembers(context, type);
Expand Down Expand Up @@ -367,21 +364,6 @@ function validateObjectInterfaces(
});
}

function validateInterfaces(
context: SchemaValidationContext,
iface: GraphQLInterfaceType,
): void {
const possibleTypes = context.schema.getPossibleTypes(iface);

if (possibleTypes.length === 0) {
context.reportError(
`Interface ${iface.name} must be implemented ` +
`by at least one Object type.`,
iface.astNode,
);
}
}

function validateObjectImplementsInterface(
context: SchemaValidationContext,
object: GraphQLObjectType,
Expand Down