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

[Question] How would you send properly send error for GQL Subcriptions #1104

Open
Moonnz opened this issue Aug 8, 2024 · 2 comments
Open

Comments

@Moonnz
Copy link
Contributor

Moonnz commented Aug 8, 2024

Hello :)

I've been using Mercurius with NestJS without any issues until now. However, as I'm implementing a subscription, I'm finding it challenging to properly send errors through the subscription WebSocket in accordance with the graphql-ws protocol.

I haven't been able to find any resources on this within the NestJS ecosystem, and it seems there isn't much available within the Mercurius ecosystem either.

Has anyone here managed to handle this or encountered something similar? Any relevant insights would be greatly appreciated!

@Moonnz
Copy link
Contributor Author

Moonnz commented Aug 8, 2024

I will create a real issue here, but apparently it's caused by thoose lines of code in the subscription-connection.js file :

case this.protocolMessageTypes.GQL_START: {
  if (this.isReady) {
    this.handleGQLStart(data).catch((e) => {
      this.sendMessage(
        this.protocolMessageTypes.GQL_ERROR,
        id,
        e.message
      )
    })
  }

The graphql-ws protocol said the payload should be an Array of GraphqlError

@Moonnz
Copy link
Contributor Author

Moonnz commented Aug 9, 2024

#1105

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

No branches or pull requests

1 participant