Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b418ba

Browse filesBrowse files
authored
fix: Disable entity keys validation (#22)
* fix: Do not validate entity keys * test: Fix tests
1 parent 61772cc commit 2b418ba
Copy full SHA for 2b418ba

File tree

Expand file treeCollapse file tree

2 files changed

+0
-55
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+0
-55
lines changed

‎src/Types/EntityObjectType.php

Copy file name to clipboardExpand all lines: src/Types/EntityObjectType.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ private function validateReferenceResolver()
109109
private function validateReferenceKeys($ref)
110110
{
111111
Utils::invariant(isset($ref['__typename']), 'Type name must be provided in the reference.');
112-
113-
$refKeys = array_keys($ref);
114-
$refContainsKeys = !empty(array_intersect($this->getKeyFields(), $refKeys));
115-
116-
Utils::invariant($refContainsKeys, 'Key fields are missing from the entity reference.');
117112
}
118113

119114
public static function validateResolveReference(array $config)

‎test/EntitiesTest.php

Copy file name to clipboardExpand all lines: test/EntitiesTest.php
-50Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -86,56 +86,6 @@ public function testResolvingEntityReference()
8686
$this->assertEquals($expectedRef, $actualRef);
8787
}
8888

89-
public function testResolvingEntityReferenceWithoutAllKeys()
90-
{
91-
$expectedRef = [
92-
'id' => 1,
93-
'email' => 'luke@skywalker.com',
94-
'firstName' => 'Luke',
95-
'lastName' => 'Skywalker',
96-
'__typename' => 'User'
97-
];
98-
99-
$userType = new EntityObjectType([
100-
'name' => 'User',
101-
'keyFields' => ['id', 'email'],
102-
'fields' => [
103-
'id' => ['type' => Type::int()],
104-
'email' => ['type' => Type::string()],
105-
'firstName' => ['type' => Type::string()],
106-
'lastName' => ['type' => Type::string()]
107-
],
108-
'__resolveReference' => function () use ($expectedRef) {
109-
return $expectedRef;
110-
}
111-
]);
112-
113-
$actualRef = $userType->resolveReference(['email' => 'luke@skywalker.com', '__typename' => 'User']);
114-
115-
$this->assertEquals($expectedRef, $actualRef);
116-
}
117-
118-
public function testResolvingEntityReferenceWithoutAnyKeys()
119-
{
120-
$userType = new EntityObjectType([
121-
'name' => 'User',
122-
'keyFields' => ['id', 'email'],
123-
'fields' => [
124-
'id' => ['type' => Type::int()],
125-
'email' => ['type' => Type::string()],
126-
'firstName' => ['type' => Type::string()],
127-
'lastName' => ['type' => Type::string()]
128-
],
129-
'__resolveReference' => function () {
130-
return null;
131-
}
132-
]);
133-
134-
$this->expectException(InvariantViolation::class);
135-
136-
$userType->resolveReference(['__typename' => 'User']);
137-
}
138-
13989
public function testCreatingEntityRefType()
14090
{
14191
$userTypeKeyFields = ['id', 'email'];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.