Skip to content

Is there an example for GraphQL Subscriptions? #88

Answered by Papooch
lodeli-lulu asked this question in Q&A
Discussion options

You must be logged in to vote

If the decorator function has the same this context as the class, you can just use the already injected ClsService, if not, you'll need to use the static ClsServiceManager to retrieve the singleton ClsService instance.

Then just wrap the middleware call and pass in the store:

return await this.clsService.runWith(context.__CLS_STORE__, () => {
  return // ... call the middleware
})

The context will be then preserved within this callback/promise chain.

(remember that cls.run/With returns whatever the callback returns)

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@lodeli-lulu
Comment options

@Papooch
Comment options

Answer selected by lodeli-lulu
@lodeli-lulu
Comment options

@Papooch
Comment options

@lodeli-lulu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants