Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is responseMiddleware not a part of the .request flow? #982

Closed
IgnisDa opened this issue Jul 15, 2024 · 1 comment
Closed

Is responseMiddleware not a part of the .request flow? #982

IgnisDa opened this issue Jul 15, 2024 · 1 comment

Comments

@IgnisDa
Copy link

IgnisDa commented Jul 15, 2024

What

I am using graphql-request in Remix, which supports directs using throw Response.json(). I added this approach in my responseMiddleware which ensures that if there are certain error codes in the response, user is logged out. But instead of the redirect happenning, my server crashes with the following error:

image

Would it be possible to add a middleware that will always run when calling gqlClient.request() before returning the data?

@jasonkuhrt
Copy link
Owner

Throwing HTTP responses is not something that we will support directly. The new middleware system in Graffle will chain thrown errors using .cause.

You could write your own error handler to discover when an error cause is an HTTP response and if it is throw it directly for Remix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants