Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription Chat Application full example does not return message data #1133

Closed
alico-cra opened this issue Nov 13, 2023 · 2 comments
Closed

Comments

@alico-cra
Copy link

Following the example subscription app provided here: https://github.com/mirumee/ariadne-graphql-chat-example
It appears that the object being yielded back is returning data as null.
The query goes through the resolver as expected and logging the content before it yields contains the correct data.

I am using local memory for communication, and the Broadcast package.

broadcast = Broadcast("memory://")

mutation = MutationType()

@mutation.field("send")
async def resolve_send(*_, **message):
    print("Send", message, json.dumps(message))
    await broadcast.publish(channel="chatroom", message=json.dumps(message))
    return True

subscription = SubscriptionType()

@subscription.source("message")
async def source_message(_, info):
    async with broadcast.subscribe(channel="chatroom") as subscriber:
        async for event in subscriber:
            print("Event", event, event.message)
            yield json.loads(event.message)
app = Starlette(
    debug=True,
    on_startup=[broadcast.connect],
    on_shutdown=[broadcast.disconnect],
)
# Mount app to handle GET and POST methods
app.mount("/graphql/", graphql)

# Mount app to handle websocket connections
app.add_websocket_route("/graphql/", graphql)

image

image

Is this a GraphiQL issue? Or perhaps an issue with using local memory as opposed to something like redis?

@rafalp
Copy link
Contributor

rafalp commented Nov 14, 2023

Hey, thanks for reporting. I'll investigate.

@rafalp rafalp closed this as completed Nov 14, 2023
@rafalp rafalp reopened this Nov 14, 2023
@rafalp
Copy link
Contributor

rafalp commented Jan 26, 2024

This seems to be an issue with local memory storage. The setup that repo uses is working without any changes, even GraphiQL subscribes to updates:

Zrzut ekranu 2024-01-26 o 14 01 55

@rafalp rafalp closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants