graphene-subscriptions icon indicating copy to clipboard operation
graphene-subscriptions copied to clipboard

Receiving updates twice per change

Open aswinshenoy opened this issue 5 years ago • 4 comments

I am receiving updates twice per change (like a save). Everything else is working totally fine if I ignore the repetition. Is this due to some mistake in configuration from my part?

image

I use the following custom snippet to send update -

.
.
team.save()
event = SubscriptionEvent(
    operation='TEAM_STATE_CHANGE',
    instance=team
)
event.send()

I had earlier tried with post_save.connect(post_save_subscription, sender=Team, dispatch_uid="team_post_save") which also resulted in updates being dispatched twice per change/save, so I decided to try with the above custom event but it still doesn't seem to solve the issue.

This is my subscription resolver -

def resolve_teamUpdates(root, info, roomID):
    return root.filter(
        lambda event:
        (
            (
                event.operation == 'TEAM_JOIN_ROOM' or
                event.operation == 'TEAM_STATE_CHANGE' or
                event.operation == 'TEAM_LEAVE_ROOM'
            ) and
            isinstance(event.instance, Team) and
            event.instance.room.id == int(roomID)
        )
    ).map(lambda event: event)

Also in my django logs, I couldn't see anything surprising. image

I am using a Daphne ASGI server & Django >3.0 (and react apollo in the client-side).

aswinshenoy avatar Aug 06 '20 09:08 aswinshenoy

I'm facing the same issue. Subscription is fired twice at every single update.

tronxdev avatar Aug 21 '20 12:08 tronxdev

facing same issue, any updates?

ad3bay0 avatar Aug 23 '20 21:08 ad3bay0

eventually used this https://github.com/datadvance/DjangoChannelsGraphqlWs worked like a charm and easier to set up

ad3bay0 avatar Aug 25 '20 22:08 ad3bay0

I also have this issue, and I receive a subscription event for every person that is subscribed. So if there are 10 subscriptions, one change occurs, every subscriber receives 10 event notifications

Bit the bullet. Updated to DjangoChannelsGraphqlWs as @ad3bay0 suggested. It's a much better library

techknowfile avatar Feb 11 '21 21:02 techknowfile