Skip to content

Commit 175ace7

Browse files
committed
Spec compliance: do not require interfaces to have at least one implementor
graphql/graphql-spec#459
1 parent fef556a commit 175ace7

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

src/Type/SchemaValidationContext.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ public function validateTypes()
270270
} elseif ($type instanceof InterfaceType) {
271271
// Ensure fields are valid.
272272
$this->validateFields($type);
273-
274-
// Ensure Interfaces include at least 1 Object type.
275-
$this->validateInterfaces($type);
276273
} elseif ($type instanceof UnionType) {
277274
// Ensure Unions include valid member types.
278275
$this->validateUnionMembers($type);
@@ -517,23 +514,6 @@ private function validateObjectInterfaces(ObjectType $object)
517514
}
518515
}
519516

520-
private function validateInterfaces(InterfaceType $iface)
521-
{
522-
$possibleTypes = $this->schema->getPossibleTypes($iface);
523-
524-
if (count($possibleTypes) !== 0) {
525-
return;
526-
}
527-
528-
$this->reportError(
529-
sprintf(
530-
'Interface %s must be implemented by at least one Object type.',
531-
$iface->name
532-
),
533-
$iface->astNode
534-
);
535-
}
536-
537517
/**
538518
* @param InterfaceType $iface
539519
*

tests/Type/ValidationTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ interface SomeInterface {
15621562
}
15631563

15641564
/**
1565-
* @see it('rejects an interface not implemented by at least one object')
1565+
* @see it('accepts an interface not implemented by at least one object')
15661566
*/
15671567
public function testRejectsAnInterfaceNotImplementedByAtLeastOneObject()
15681568
{
@@ -1577,11 +1577,7 @@ interface SomeInterface {
15771577
');
15781578
$this->assertMatchesValidationMessage(
15791579
$schema->validate(),
1580-
[[
1581-
'message' => 'Interface SomeInterface must be implemented by at least one Object type.',
1582-
'locations' => [[ 'line' => 6, 'column' => 7 ]],
1583-
],
1584-
]
1580+
[]
15851581
);
15861582
}
15871583

0 commit comments

Comments
 (0)