From d23252707d05170ca757feb35e4a25fc72a9ddcd Mon Sep 17 00:00:00 2001 From: qlient-org <90476638+qlient-org@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:56:27 +0100 Subject: [PATCH] Add qlient as a python client. --- .../language-support/python/client/qlient.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/content/code/language-support/python/client/qlient.md diff --git a/src/content/code/language-support/python/client/qlient.md b/src/content/code/language-support/python/client/qlient.md new file mode 100644 index 0000000000..b5d2cab06c --- /dev/null +++ b/src/content/code/language-support/python/client/qlient.md @@ -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 +```