File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
src/content/code/language-support/python/client Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ name : Qlient
3+ description : A fast and modern graphql client designed with simplicity in mind.
4+ url : https://github.com/qlient-org/python-qlient
5+ github : qlient-org/python-qlient
6+ ---
7+
8+ Here's an example of a qlient hello world.
9+
10+ first install the library:
11+
12+ ``` bash
13+ pip install qlient
14+ ```
15+
16+ Create a ` swapi_client_example.py ` file with this content:
17+
18+ ``` python
19+ from qlient import Client, GraphQLResponse
20+
21+ client = Client(" https://swapi-graphql.netlify.app/.netlify/functions/index" )
22+
23+ res: GraphQLResponse = client.query.film(
24+ # swapi graphql input fields
25+ id = " ZmlsbXM6MQ==" ,
26+
27+ # qlient specific
28+ _fields = [" id" , " title" , " episodeID" ]
29+ )
30+
31+ print (res.query) # query film($id: ID) { film(id: $id) { id title episodeID } }
32+ print (res.variables) # {'id': 'ZmlsbXM6MQ=='}
33+ print (res.data) # {'film': {'id': 'ZmlsbXM6MQ==', 'title': 'A New Hope', 'episodeID': 4}}
34+ ```
35+
36+ Close the file and run it using python:
37+
38+ ``` bash
39+ python swapi_client_example.py
40+ ```
You can’t perform that action at this time.
0 commit comments