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

Feature Request: Support Graphql subscription #5

Open
miketwo opened this issue Oct 4, 2023 · 1 comment
Open

Feature Request: Support Graphql subscription #5

miketwo opened this issue Oct 4, 2023 · 1 comment

Comments

@miketwo
Copy link

miketwo commented Oct 4, 2023

I'm not exactly sure how to modify the code to achieve this, but I think it would involve two things:

  • being able to pass the subprotocols arg to websockets.connect()
  • being able to send a subscription query on connect

Example working code:

async def capture_data():
  uri = "ws://localhost:8000/graphql"
  start = {
    "type": "start",
    "payload": {"query": "subscription { whatever }"}
  }
  async with websockets.connect(uri, subprotocols=["graphql-ws"]) as websocket:
    await websocket.send(json.dumps(start))
    while True:
      data = await websocket.recv()
      handle_msg(json.loads(data))
@kirankumbhar
Copy link
Owner

Hey @miketwo
Can you explain the problem you are trying to solve in the detail? More context would be helpful to modify the WebSocket connection to allow some custom arguments.

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