relay-tools / react-relay-network-layer

ReactRelayNetworkLayer with middlewares and query batching for Relay Classic.
MIT License
277 stars 47 forks source link

Rendering partial response with error messages #44

Closed jwb closed 7 years ago

jwb commented 7 years ago

Our GraphQL service relies on a number of downstream services, some of which have occasional outages. We'd like the Relay rendering to proceed when there are errors reported using partial data in the response.

One thing that we're really not clear on is how we might pass the information in the errors to the render. Is this something that anyone here could provide an example for? There is a suggestion in the relay issues, but it doesn't give any hint how one would transmit the error message(s) to the React components.

nodkz commented 7 years ago

I can sugfest two variants: 1) GraphQL on server should catch outages and return normal response to your client without throwing error, but including some notice to payload (recommend). 2) Use some global emitter. Component subscribes on mount to emitter and unsub on unmount. And you add custom middleware to this RRNL which catch outage errors and emit them.