diff --git a/src/Types/EntityObjectType.php b/src/Types/EntityObjectType.php index 8bb7c57..f2e70ad 100644 --- a/src/Types/EntityObjectType.php +++ b/src/Types/EntityObjectType.php @@ -109,11 +109,6 @@ private function validateReferenceResolver() private function validateReferenceKeys($ref) { Utils::invariant(isset($ref['__typename']), 'Type name must be provided in the reference.'); - - $refKeys = array_keys($ref); - $refContainsKeys = !empty(array_intersect($this->getKeyFields(), $refKeys)); - - Utils::invariant($refContainsKeys, 'Key fields are missing from the entity reference.'); } public static function validateResolveReference(array $config) diff --git a/test/EntitiesTest.php b/test/EntitiesTest.php index 155f4d3..de61813 100644 --- a/test/EntitiesTest.php +++ b/test/EntitiesTest.php @@ -86,56 +86,6 @@ public function testResolvingEntityReference() $this->assertEquals($expectedRef, $actualRef); } - public function testResolvingEntityReferenceWithoutAllKeys() - { - $expectedRef = [ - 'id' => 1, - 'email' => 'luke@skywalker.com', - 'firstName' => 'Luke', - 'lastName' => 'Skywalker', - '__typename' => 'User' - ]; - - $userType = new EntityObjectType([ - 'name' => 'User', - 'keyFields' => ['id', 'email'], - 'fields' => [ - 'id' => ['type' => Type::int()], - 'email' => ['type' => Type::string()], - 'firstName' => ['type' => Type::string()], - 'lastName' => ['type' => Type::string()] - ], - '__resolveReference' => function () use ($expectedRef) { - return $expectedRef; - } - ]); - - $actualRef = $userType->resolveReference(['email' => 'luke@skywalker.com', '__typename' => 'User']); - - $this->assertEquals($expectedRef, $actualRef); - } - - public function testResolvingEntityReferenceWithoutAnyKeys() - { - $userType = new EntityObjectType([ - 'name' => 'User', - 'keyFields' => ['id', 'email'], - 'fields' => [ - 'id' => ['type' => Type::int()], - 'email' => ['type' => Type::string()], - 'firstName' => ['type' => Type::string()], - 'lastName' => ['type' => Type::string()] - ], - '__resolveReference' => function () { - return null; - } - ]); - - $this->expectException(InvariantViolation::class); - - $userType->resolveReference(['__typename' => 'User']); - } - public function testCreatingEntityRefType() { $userTypeKeyFields = ['id', 'email'];