Description
Describe the bug
I have a custom checker middleware that I'm using on regular queries with @UseMiddleware(CustomMiddleware), when I try to use that on a subscription, the middleware is not called when the subscription is first queried (which is when authorization checks should happen). The middleware is called when the resolver receives a pubsub message.
However, if I use @Authorized(), the auth checker middleware gets called when you first query the subscription.
To Reproduce
@UseMiddleware(CustomMiddlware)
@Subscription(
topics: 'SOME_TOPIC'
)
async mySubscription()
// Middleware will only get called when a new message comes in.
Expected behavior
Middleware should get called when first subscribing to the subscription (onConnect)
Environment (please complete the following information):
- OS: any
- Node 13.12.0
- Package version: 0.18.0-beta.10 (also tested on 0.17.6)
- TypeScript version 3.8.3
Additional context
I've set up a minimal test repo here https://github.com/rigelglen/typegraphql-middleware-subscription-test
You can reproduce using the following
subscription{
normalSubscriptionWithMiddleware{
id
message
date
}
}
And then
mutation {
pubSubMutation(message: "something")
}