-
-
Notifications
You must be signed in to change notification settings - Fork 900
fix: return null instead of exception for GraphQL Query operation #6118
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
fix: return null instead of exception for GraphQL Query operation #6118
Conversation
…ation when item not found
@@ -68,6 +69,10 @@ public function provide(Operation $operation, array $uriVariables = [], array $c | |||
$item = null; | |||
} | |||
|
|||
if ($operation instanceof Query && null === $item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be at line 86 that we check if the $item
is not null? Also can you add a non regression test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it above because it looks like condition !\is_object($item)
on line 86 is related to Subscription and Mutation operations logic and $item
should be checked on null before it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for test - I did it but unfortunately ApiPlatform\Exception\ItemNotFoundException
is outside of GraphQL directory and I cannot mock IriConvertorInterface
to throw this exception. Used class_alias
to make it work, not sure if it's OK.
Hello, do you have any updates on this fix? The issue #6072 contains information that an update to the latest 3.2.x should fix it, but the fix seems to not be merged. :D If I can help you in any way, feel free to contact me. :) |
29e27f4
to
d0be2ba
Compare
3.2
After upgrading to 3.2 we noticed a new error
Item from read provider should be a nullable object.
in our projects, when request single resource via GraphQL Query if such resource does not exists with provided id, see #6072.