GraphQL ReadProvider "Item from read provider should be a nullable object."
API Platform version(s) affected: 3.2.7
Description
I am getting "Item from read provider should be a nullable object." error when I request a single item via GraphQL query if item with that id does not exist. When item exists then it is working properly.
I debugged a little bit and found following infos:
-
error is thrown here: https://github.com/api-platform/core/blob/a749fe8494a5b3ca41139a418ed1e29c3e7b33a6/src/GraphQl/State/Provider/ReadProvider.php#L82
-
on line 66 of ReadProvider
ItemNotFoundExceptionwas thrown and caught here: https://github.com/api-platform/core/blob/a749fe8494a5b3ca41139a418ed1e29c3e7b33a6/src/GraphQl/State/Provider/ReadProvider.php#L68
I am new to GraphQL so I don't know if it is the correct behaviour.
How to reproduce
Try to fetch an item that does not exist via GraphQL API
Possible Solution
Should not it just return null if item is not found instead of throwing an exception?
Additional Context
Same here
please update to latest 3.2.
we should probably just use the same logic that I see at https://github.com/api-platform/core/blob/a749fe8494a5b3ca41139a418ed1e29c3e7b33a6/src/GraphQl/State/Provider/ReadProvider.php#L71
I would be curious to see what test fail on this use case. Feel free to patch it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.