GraphQL error handling in Relay Modern
I think error handling is a little bit weird. Contra the example in https://facebook.github.io/relay/docs/network-layer.html, it looks like I need to actually `throw` an `Error` in the event that there are any query errors. I can't just pass through the `graphql` object with the `errors` property. This is because in https://github.com/facebook/relay/blob/v1.1.0/packages/relay-runtime/network/RelayNetwork.js#L197-L208, `normalizePayload` only throws an error if `data` is nully. But the forward `throw` branch there is the only code path that will trigger `onError` for the request, and correspondingly the only path that will hit `onError` in `<QueryRenderer>` per https://github.com/facebook/relay/blob/v1.1.0/packages/react-relay/modern/ReactRelayQueryRenderer.js#L205-L212. Otherwise we hit `onNext` per https://github.com/facebook/relay/blob/v1.1.0/packages/react-relay/modern/ReactRelayQueryRenderer.js#L229, and will always set `error: null` on the `readyState` that gets passed to the `render` callback. This is weird. Am I missing something, or are things supposed to work this way?
Posted by taion on Jun 23, 2017, 9:54 PM
Tags
Related issues
- [UPDATE NOW] PHP RCE Vulnerability (CVE-2026-109618 and CVE-2026-109619)
- Server requests and latency increased after upgrading from Next.js 15 to 16
- Leak of Geedge Networks internal documents (100,000+ from Jira, Confluence, GitLab)
- Can't download videos from YouTube on cobalt.tools
- `google_service_networking_connection` produce an error when trying to destroy the resource
- WebGPU-based renderer for the editor
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Network)
[UPDATE NOW] PHP RCE Vulnerability (CVE-2026-109618 and CVE-2026-109619)
Server requests and latency increased after upgrading from Next.js 15 to 16
Leak of Geedge Networks internal documents (100,000+ from Jira, Confluence, GitLab)
Can't download videos from YouTube on cobalt.tools
`google_service_networking_connection` produce an error when trying to destroy the resource
WebGPU-based renderer for the editor
Zed downloads NodeJS binary and npm packages from Internet without user’s consent
FR: Allow custom domains for Tailscale Funnel
GraphQL error handling in Relay Modern
I think error handling is a little bit weird. Contra the example in https://facebook.github.io/relay/docs/network-layer.html, it looks like I need to actually `throw` an `Error` in the event that there are any query errors. I can't just pass through the `graphql` object with the `errors` property. This is because in https://github.com/facebook/relay/blob/v1.1.0/packages/relay-runtime/network/RelayNetwork.js#L197-L208, `normalizePayload` only throws an error if `data` is nully. But the forward `throw` branch there is the only code path that will trigger `onError` for the request, and correspondingly the only path that will hit `onError` in `<QueryRenderer>` per https://github.com/facebook/relay/blob/v1.1.0/packages/react-relay/modern/ReactRelayQueryRenderer.js#L205-L212. Otherwise we hit `onNext` per https://github.com/facebook/relay/blob/v1.1.0/packages/react-relay/modern/ReactRelayQueryRenderer.js#L229, and will always set `error: null` on the `readyState` that gets passed to the `render` callback. This is weird. Am I missing something, or are things supposed to work this way?
Comments (0)
No comments yet. Start the discussion.