Fork me on GitHub
#graphql
<
2021-09-29
>
Lennart Buit14:09:52

So on the topic of subscriptions. Our schema has a dataloader (superlifter) that is started in an interceptors :enter, and cleaned up in an interceptors :leave . Now, in the lacinia.pedestals subscription attaching, I can pass an interceptor chain, but it seems that the chain is executed in both directions prior to me even calling source-stream . So I was wondering whether there is a way to do ‘around’ actions like this for single invocations of source-stream. I mean, like ‘data loader start’ -> ‘source stream calling’ -> ‘nested selection resolving (using the dataloader)’ -> ‘dataloader cleanup’.

👀 3
Lennart Buit14:09:02

I tried to do the obvious, right, starting the dataloader, calling source stream, stopping the dataloader. But source-stream returns immediately. As far as I can tell before executing the nested selection. So the dataloader is cleaned up prior to it being needed :’).

Lennart Buit08:09:23

So a solution I came up with is running an interceptor chain around resolving the query after a value was produced on the source-stream. Therefore, I have made a slight alteration of the execute-operation-interceptor interceptor to do so. I don’t know what to think about it, tho…