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

how to use type-graphql subscription #5

Open
ceddybi opened this issue Oct 9, 2024 · 2 comments
Open

how to use type-graphql subscription #5

ceddybi opened this issue Oct 9, 2024 · 2 comments

Comments

@ceddybi
Copy link

ceddybi commented Oct 9, 2024

Hi @hansottowirtz super awesome work!

I was trying to get subscriptions working with type-graph schema, but the resolveSubscription doesn't get the topic and filter

Can i provide the example repo ?

@ceddybi
Copy link
Author

ceddybi commented Oct 9, 2024

@ceddybi
Copy link
Author

ceddybi commented Oct 25, 2024

@hansottowirtz

when you're publishToConnections, why do you have to execute the schema knowing the handler has been modified, why not just return the payload to the websocket as is like you commented here

// execution of subscription with payload as the root (can be modified within the resolve callback defined in schema)
// will return the payload as is by default
const payload = await execute({
  schema: schema,
  document: parse(sub.subscription.query),
  rootValue: eventPayload,
  contextValue: graphqlContext,
  variableValues: sub.subscription.variables,
  operationName: sub.subscription.operationName,
});

// transform it into ws message (id is not specific to connection but to subscription)
const message: NextMessage = {
  id: sub.id,
  type: MessageType.Next,
  payload,
};

why not just send the payload as is without the execute, i think the execute is not effective.

const message: NextMessage = {
  id: sub.id,
  type: MessageType.Next,
  payload: eventPayload
};

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