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

Use error formatter for subscription GQL errors #967

Merged
merged 1 commit into from
Feb 22, 2023
Merged

Use error formatter for subscription GQL errors #967

merged 1 commit into from
Feb 22, 2023

Conversation

LewisYearsley
Copy link
Contributor

RE: #966

Currently, if there are graphql errors returned from a subscription in the standard "errors" property on a response - these do not get the opportunity to be passed through the potentially provided errorFormatter. This means any formatting and any side effects you may have in the error formatter are not run for these cases.

This PR applies the provided error formatter or merely the default error formatter as a fallback.

NOTE:

I'm not 100% convinced on this change as is, my main thing is that in the case of mutation/query, we get to override the status code for the response in addition to the main payload. This doesn't apply to subscriptions and therefore that is thrown away in that case. It will work, but semantically may be slightly weird. Open to feedback and suggestions of course.

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
Copy link
Collaborator

This seems correct.

Copy link
Contributor

@marco-ippolito marco-ippolito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM good job!

Copy link
Contributor

@jonnydgreen jonnydgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcollina mcollina merged commit 6af015a into mercurius-js:master Feb 22, 2023
@LewisYearsley LewisYearsley deleted the subscriptions-error-formatter branch February 22, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants