Skip to content

GraphQL Http client #5

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

Closed
wants to merge 6 commits into from

Conversation

BharathaAravind
Copy link
Contributor

@BharathaAravind BharathaAravind commented Mar 27, 2019

A Basic Http Client to support Query and Mutations over http.

Sample Query Usage:

from  graphql_client import GraphQLHttpClient

httpClient = GraphQLHttpClient.GraphQLHttpClient("http://localhost:8080/graphql")
q = """
  query ($limit: Int!) {
    notifications (order_by: {created: "desc"}, limit: $limit) {
      id
      title
      content
    }
  }
"""
response = httpClient.query(query=q, variables={'limit': 10})
print(response.text)

Even the mutation works the same way. It internally calls query itself.

from  graphql_client import GraphQLHttpClient
httpClient = GraphQLHttpClient.GraphQLHttpClient("http://localhost:8080/graphql")
mutation = """
  mutation{
    uploadData(file:"xxx/somefilepath.txt"){
    id
  }
}
"""
response = httpClient.mutation(query=mutation)

@ecthiender
Copy link
Owner

There should be one client which can use a specified transport (HTTP or websocket). Closing this in favour of a better design in #17 .

Thanks for all your work @BharathaAravind . Please feel free to contribute anything else, if you would like.

@ecthiender ecthiender closed this Apr 10, 2020
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

Successfully merging this pull request may close these issues.

2 participants