How to use dataloaders with graphql-ws subscriptions? #198
-
I am trying to use dataloaders for caching execution result of my subscription. I was planning to write a custom I noticed that graphql-ws does not call Is there an alternative to defining my on subscribe method ? That would be a little complicated, and not useful since I just need to replace the I see that graphql/graphql-js#3071 tries to do the same. Any other alternatives till this is merged ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can provide a custom Lines 162 to 170 in 784ea15 Right now |
Beta Was this translation helpful? Give feedback.
You can provide a custom
subscribe
function as an option.graphql-ws/src/server.ts
Lines 162 to 170 in 784ea15
Right now
execute
function is an implementation detail ofsubscribe
and thus there is no option to replace it. However, writing your own is pretty straight-forward: https://github.com/dotansimha/envelop/pull/183/files#diff-8172edfaa44ae…