Skip to content

Commit

Permalink
Spec compliance: do not require interfaces to have at least one imple…
Browse files Browse the repository at this point in the history
  • Loading branch information
vladar committed Aug 29, 2019
1 parent fef556a commit 175ace7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
20 changes: 0 additions & 20 deletions src/Type/SchemaValidationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ public function validateTypes()
} elseif ($type instanceof InterfaceType) {
// Ensure fields are valid.
$this->validateFields($type);

// Ensure Interfaces include at least 1 Object type.
$this->validateInterfaces($type);
} elseif ($type instanceof UnionType) {
// Ensure Unions include valid member types.
$this->validateUnionMembers($type);
Expand Down Expand Up @@ -517,23 +514,6 @@ private function validateObjectInterfaces(ObjectType $object)
}
}

private function validateInterfaces(InterfaceType $iface)
{
$possibleTypes = $this->schema->getPossibleTypes($iface);

if (count($possibleTypes) !== 0) {
return;
}

$this->reportError(
sprintf(
'Interface %s must be implemented by at least one Object type.',
$iface->name
),
$iface->astNode
);
}

/**
* @param InterfaceType $iface
*
Expand Down
8 changes: 2 additions & 6 deletions tests/Type/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ interface SomeInterface {
}

/**
* @see it('rejects an interface not implemented by at least one object')
* @see it('accepts an interface not implemented by at least one object')
*/
public function testRejectsAnInterfaceNotImplementedByAtLeastOneObject()
{
Expand All @@ -1577,11 +1577,7 @@ interface SomeInterface {
');
$this->assertMatchesValidationMessage(
$schema->validate(),
[[
'message' => 'Interface SomeInterface must be implemented by at least one Object type.',
'locations' => [[ 'line' => 6, 'column' => 7 ]],
],
]
[]
);
}

Expand Down

0 comments on commit 175ace7

Please sign in to comment.