What is the difference between onOperation and onSubscribe hooks ? #161
-
Hey, I was going through the graphql-ws docs, and found that here we have 2 different hooks:
My understanding is that when I make a new graphql subscription, the hooks are executed in the following order:
Am I missing anything out in this ? So if this is the order, then in the I previously used |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You might be mixing "subscribe" with GraphQL subscriptions, but that is not the case. The client "subscribes" for events on the server, Lines 619 to 654 in f24e9ba
Lines 676 to 690 in f24e9ba |
Beta Was this translation helpful? Give feedback.
You might be mixing "subscribe" with GraphQL subscriptions, but that is not the case. The client "subscribes" for events on the server,
onSubscribe
is the first to be called. It allows you to manipulate the the execution arguments and skip the built-in validation and exec args construction. With it you can use dynamic schemas, implement persisted queries, skip validation, apply custom auth or introduce completely custom subscription behaviour (check the recipes out). Check it out here:graphql-ws/src/server.ts
Lines 619 to 654 in f24e9ba