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

detect disconnect

Open unimonkiez opened this issue 5 years ago • 0 comments

  • GraphQL AioWS version: 0.3.1
  • Python version: 3.8.6
  • Operating System: MacOS Catalina

Description

Trying to figure out how to know when someone isn't subscribed anymore.

What I Did

Ran the example which works great but unable to know when someone is disconnected..

import asyncio
import graphene


class Subscription(graphene.ObjectType):
    count_seconds = graphene.Float(up_to=graphene.Int())

    async def resolve_count_seconds(root, info, up_to=5):
        for i in range(up_to):
            print("YIELD SECOND", i)
            yield i
            await asyncio.sleep(1.)
        yield up_to

schema = graphene.Schema(subscription=Subscription)

unimonkiez avatar Oct 14 '20 13:10 unimonkiez