Skip to content

Count active subscriptions #2719

Discussion options

You must be logged in to vote

Hey @AlexanderWells-diamond, currently I can't think of an trivial way to achieve this. The aiohttp view creates a new instance of strawberry.aiohttp.handles.GraphQLTransportWSHandler for each incoming ws connection using the graphql-transport-ws protocol. You could subclass said class and extend its handle_request method to keep track of individual connections by updating some global counter.

The code could look roughtly like this:

from strawberry.aiohttp.handlers import GraphQLTransportWSHandler
from strawberry.aiohttp.views import GraphQLView
from aiohttp import web

some_global_counter = 0


class CustomHandler(GraphQLTransportWSHandler):
  async def handle_request(self):
    some_glo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@AlexanderWells-diamond
Comment options

@AlexanderWells-diamond
Comment options

Answer selected by AlexanderWells-diamond
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