-
Notifications
You must be signed in to change notification settings - Fork 11
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
context manager bug #33
Comments
Hi @bennnym , thanks for the bug report. I think the error happens because there is no support for context manager yet. Would you mind opening a PR to support it? Otherwise I can take a look at this in few days. |
Hi @ecthiender, I didn't realise it wasn't supported. Why is it in the examples on the readme if it isn't? |
@bennnym sorry I'm dumb. It is supported. I tried this code (same as your code, adding missing variables) and it seems to work: import time
from graphql_client import GraphQLClient
endpoint = 'ws://localhost:8080/graphql'
new_header = {
'authorization': 'secret'
}
subscription = """
subscription {
notifications {
id
title
content
}
}
"""
def callback(_id, data):
print("got new data..")
print(f"msg id: {_id}. data: {data}")
with GraphQLClient(endpoint) as client:
sub_id = client.subscribe(subscription,
# variables={'limit': 10},
headers=new_header,
callback=callback)
print('got sub id', sub_id)
time.sleep(2)
client.stop_subscribe(sub_id) I get this output:
|
running the simple example on the homepage
returns the following:
The text was updated successfully, but these errors were encountered: