graphql-core icon indicating copy to clipboard operation
graphql-core copied to clipboard

Can subscriptions have middleware?

Open nrbnlulu opened this issue 3 years ago • 2 comments

In execute you can pass a MiddlewareManager is there an alternative for subscribe? I want to run code before a resolver is called.

nrbnlulu avatar Jan 04 '23 10:01 nrbnlulu

This is currently not supported, but you can probably use a custom execution context as a workaround.

I will try to get this as a new feature into the next version. Maybe you can post a small example code how you expect it to work which I can then use as the basis for unit testing the feature.

Cito avatar Jan 04 '23 15:01 Cito

Hi, strawberry has some good example https://strawberry.rocks/docs/guides/custom-extensions#resolve

we use this here: https://github.com/strawberry-graphql/strawberry/blob/feacc0f186458d138ba0231a006317cadb0b7753/strawberry/schema/execute.py#L119

nrbnlulu avatar Jan 06 '23 12:01 nrbnlulu