Skip to content

Add qlient as a python client. #1203

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

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/content/code/language-support/python/client/qlient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Qlient
description: A fast and modern graphql client designed with simplicity in mind.
url: https://github.com/qlient-org/python-qlient
github: qlient-org/python-qlient
---

Here's an example of a qlient hello world.

first install the library:

```bash
pip install qlient
```

Create a `swapi_client_example.py` file with this content:

```python
from qlient import Client, GraphQLResponse

client = Client("https://swapi-graphql.netlify.app/.netlify/functions/index")

res: GraphQLResponse = client.query.film(
# swapi graphql input fields
id="ZmlsbXM6MQ==",

# qlient specific
_fields=["id", "title", "episodeID"]
)

print(res.query) # query film($id: ID) { film(id: $id) { id title episodeID } }
print(res.variables) # {'id': 'ZmlsbXM6MQ=='}
print(res.data) # {'film': {'id': 'ZmlsbXM6MQ==', 'title': 'A New Hope', 'episodeID': 4}}
```

Close the file and run it using python:

```bash
python swapi_client_example.py
```