Open SebaBoler opened 5 years ago
Thanks. This is a good suggestion. I will look into it. The newer python versions support async out of the box. I am not 100% familiar with subscribe, but I imagine passing an async iterable to a call back function.
If you need i can create server GraphQL with few subscription to test?
That would be nice thanks. This might take me some time. If anyone would like to contribute I'm happy to review.
Any chance to write anything in actual month??
Yea I can. Can you get the test server up?
ofc, give me 2 days. I will send info
Any updates on the issue?
I haven't had any time to work on this, but I am still waiting for the test server info.
Websocket support would indeed be great, so we can have subscriptions :)
Can you provide more details on how you would like to use a subscription API? It will help me determine the best interface.
Sorry I fear I'm not familiar enough with Python and its async library to provide a relevant feedback in API design.
In JS, this doc shows how subscription client is created, and here is the subscription API:
apolloClient.subscribe({
query: gql`
subscription onNewItem {
newItemCreated {
id
}
}`,
variables: {}
}).subscribe({
next (data) {
// Notify your application with the new arrived data
}
});
Also, you may have a look at this Python gql client that apparently supports subscriptions: https://github.com/tdip/gql-subscriptions/tree/develop
Thanks, this is helpful. I wrote something far simpler than tdip's gql subscriptions package. I also use websockets
, but the problem is that the connection must be kept alive with a while True
statement. I've posted the question here https://github.com/aaugustin/websockets/issues/581
I'm thinking of keeping the API very basic so the keep-alive problem is transferred to the developer for now. The only use case I'm testing against is whenever a subscription is received, the payload is printed. I can commit the code this weekend.
Hey, your client works perfect with Query and Mutation. Its any chance to add Subscription support >>??