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
Hey folks 👋 I'm struggling with responding with a server error. I use the typical mirage way. Say, I want to simulate 502s and test Apollo's retry mechanism, so under some fake conditions I return this for a query:
returnnewResponse(502);
But what I get returned instead is wrapped in GraphQL error. It looks like miragejs/graphql (or something internally) treats my response with 502 as a regular response and complains that the data is not returned properly:
Is it possible that miragejs/graphql is not aware that it should "re-throw" (pass) the error? Could someone give me pointers on where I should look to fill the gap?
The text was updated successfully, but these errors were encountered:
This is due to how GraphQL itself works. If the GraphQL endpoint is reachable, it wraps errors and includes them in the response. You won’t be able to simulate a 5xx type error by throwing one while resolving a query.
You should be able to override the route handler for the GraphQL endpoint where needed, though:
// Assumes `server` is the instance of the Mirage serverserver.post('<path-to-graphql>',newResponse(502))
It depends on how you’re using Mirage. I thought you mentioned testing and, if you’re using Mirage in a testing context, defining a route handler in a test is not global.
Hey folks 👋 I'm struggling with responding with a server error. I use the typical mirage way. Say, I want to simulate
502
s and test Apollo's retry mechanism, so under some fake conditions I return this for a query:But what I get returned instead is wrapped in GraphQL error. It looks like
miragejs/graphql
(or something internally) treats my response with502
as a regular response and complains that the data is not returned properly:Is it possible that
miragejs/graphql
is not aware that it should "re-throw" (pass) the error? Could someone give me pointers on where I should look to fill the gap?The text was updated successfully, but these errors were encountered: