You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a case where we have one subgraph that might have references to entities that don't exist or no longer exist. We're ok with this ending up null in the response and our schema represents that. The data is coming back in the form with want (with appropriate nulls), but there are errors that we don't care about.
In our reproduction, we're fine if the product comes back null.
This seems like #2374, but the errors I'm seeing are on the base errors and not extensions. Additionally, I don't understand how that author is successfully returning null from the __resolveReference.
There are two scenarios in the reviewData array and it probably makes sense to flip between them by commenting one of them out at a time.
The first case is where there is a productId that doesn't exist over in the product subgraph (id: 3). I've tried various ways of handling this, though ideally I would just return null from the __resolveReference and call it a day. But that raises an error Abstract type \"Product\" __resolveReference method must resolve to an Object type at runtime. I'm not sure how to handle this one. One thing I tried is a generic UnsupportedProduct, and that mostly worked, but honestly I'd rather have a null.
The second case is when the review does not have a productId. In this case, it never even tries to call the product __resolveReference. It returns the null in the data as desired, but there's an error Cannot return null for non-nullable field Product.id.. This seems like #2374, but it's on response.errors not extensions.
Thanks for the help!
The text was updated successfully, but these errors were encountered:
Issue Description
We have a case where we have one subgraph that might have references to entities that don't exist or no longer exist. We're ok with this ending up
null
in the response and our schema represents that. The data is coming back in the form with want (with appropriate nulls), but there are errors that we don't care about.In our reproduction, we're fine if the product comes back null.
This seems like #2374, but the errors I'm seeing are on the base errors and not extensions. Additionally, I don't understand how that author is successfully returning null from the __resolveReference.
Link to Reproduction
https://codesandbox.io/p/sandbox/empty-dawn-1qwky5?file=%2Fsrc%2Freviews.ts%3A9%2C32
Reproduction Steps
Run this query on port 4000 (the supergraph):
There are two scenarios in the
reviewData
array and it probably makes sense to flip between them by commenting one of them out at a time.The first case is where there is a productId that doesn't exist over in the product subgraph (id: 3). I've tried various ways of handling this, though ideally I would just return null from the __resolveReference and call it a day. But that raises an error
Abstract type \"Product\" __resolveReference method must resolve to an Object type at runtime.
I'm not sure how to handle this one. One thing I tried is a genericUnsupportedProduct
, and that mostly worked, but honestly I'd rather have a null.The second case is when the review does not have a productId. In this case, it never even tries to call the product __resolveReference. It returns the null in the data as desired, but there's an error
Cannot return null for non-nullable field Product.id.
. This seems like #2374, but it's on response.errors not extensions.Thanks for the help!
The text was updated successfully, but these errors were encountered: