https://github.com/prisma-labs/python-graphql-client
Simple GraphQL client for Python 2.7+
https://github.com/prisma-labs/python-graphql-client
graphql graphql-client python
Last synced: 4 months ago
JSON representation
Simple GraphQL client for Python 2.7+
- Host: GitHub
- URL: https://github.com/prisma-labs/python-graphql-client
- Owner: prisma-labs
- License: mit
- Created: 2016-05-12T12:09:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T10:54:50.000Z (over 5 years ago)
- Last Synced: 2026-02-01T14:53:25.013Z (5 months ago)
- Topics: graphql, graphql-client, python
- Language: Python
- Size: 16.6 KB
- Stars: 156
- Watchers: 12
- Forks: 45
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-graphql - python-graphql-client - Simple GraphQL client for Python 2.7+ (Libraries / Python Libraries)
README
# python-graphql-client
Simple GraphQL client for Python 2.7+
## Install
```sh
pip install graphqlclient
```
## Usage
```py
from graphqlclient import GraphQLClient
client = GraphQLClient('http://graphql-swapi.parseapp.com/')
result = client.execute('''
{
allFilms {
films {
title
}
}
}
''')
print(result)
```
### Authorization
Authorization tokens can be added to the request using the client's `inject_token` method:
```py
client.inject_token('very-long-and-secure-token')
```
which defaults to http header name `Authorization`.
An alternative http header name for the token can be set by passing in the alternative header name, e.g. for `x-api-key`:
```py
client.inject_token('very-long-and-secure-token','x-api-key')
```
## License
[MIT License](http://opensource.org/licenses/MIT)