graphql-engine
graphql-engine copied to clipboard
Allow to have optional remote relationships
Is your proposal related to a problem?
When a remote relationship fails, the entire query fails with a response like:
{"errors":[{"extensions":{"path":"$","code":"unexpected"},"message":"Remote server response is not valid JSON: Failed reading: not a valid json value"}]}
Describe the solution you'd like
I'd like set a remote relationship as optional or with a "silent failure", so when I query it, the error response would be within the remote relationship node itself (I think it would require a breaking change to allow an error object in this node) or to just not return it at all. Eg.:
{
product {
id
name
shipping { <-- a remote relationship
delivery_estimate
shipping_cost
}
}
}
So if the remote relationship fails for some reason, I'd still get
{
"product": {
"id": 1,
"name": "Some product",
"shipping": null
}
}
Describe alternatives you've considered
I need to show a page with all the remaining data and an error widget for the remote relationship. The only alternative I can see is doing two queries, one with the remote relationship only and another one with the remaining fields.
If the feature is approved, would you be willing to submit a PR?
Yes.