Skip to content

GraphQL Http client - #5

Closed
BharathaAravind wants to merge 6 commits into
ecthiender:masterfrom
CIShell:GraphQLHttpClient
Closed

GraphQL Http client#5
BharathaAravind wants to merge 6 commits into
ecthiender:masterfrom
CIShell:GraphQLHttpClient

Conversation

@BharathaAravind

@BharathaAravind BharathaAravind commented Mar 27, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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