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

What is the chance to add Subscription ? #11

Open
SebaBoler opened this issue Sep 26, 2018 · 12 comments
Open

What is the chance to add Subscription ? #11

SebaBoler opened this issue Sep 26, 2018 · 12 comments

Comments

@SebaBoler
Copy link

Hey, your client works perfect with Query and Mutation.
Its any chance to add Subscription support >>??

@ssshah86
Copy link
Collaborator

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.

@SebaBoler
Copy link
Author

If you need i can create server GraphQL with few subscription to test?

@ssshah86
Copy link
Collaborator

ssshah86 commented Oct 1, 2018

That would be nice thanks. This might take me some time. If anyone would like to contribute I'm happy to review.

@SebaBoler
Copy link
Author

Any chance to write anything in actual month??

@ssshah86
Copy link
Collaborator

Yea I can. Can you get the test server up?

@SebaBoler
Copy link
Author

ofc, give me 2 days. I will send info

@ghost
Copy link

ghost commented Dec 24, 2018

Any updates on the issue?

@ssshah86
Copy link
Collaborator

ssshah86 commented Jan 3, 2019

I haven't had any time to work on this, but I am still waiting for the test server info.

@waterdrop01
Copy link

Websocket support would indeed be great, so we can have subscriptions :)

@ssshah86
Copy link
Collaborator

Can you provide more details on how you would like to use a subscription API? It will help me determine the best interface.

@waterdrop01
Copy link

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

@ssshah86
Copy link
Collaborator

ssshah86 commented Mar 5, 2019

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 python-websockets/websockets#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants