11# Qlient: Python GraphQL Client
22
33[ ![ qlient-org] ( https://circleci.com/gh/qlient-org/python-qlient.svg?style=svg )] ( https://circleci.com/gh/qlient-org/python-qlient )
4- [ ![ pypi] ( https://img.shields.io/pypi/v/python- qlient.svg )] ( https://pypi.python.org/pypi/python- qlient )
5- [ ![ versions] ( https://img.shields.io/pypi/pyversions/python- qlient.svg )] ( https://github.com/qlient-org/python-qlient )
4+ [ ![ pypi] ( https://img.shields.io/pypi/v/qlient.svg )] ( https://pypi.python.org/pypi/qlient )
5+ [ ![ versions] ( https://img.shields.io/pypi/pyversions/qlient.svg )] ( https://github.com/qlient-org/python-qlient )
66[ ![ license] ( https://img.shields.io/github/license/qlient-org/python-qlient.svg )] ( https://github.com/qlient-org/python-qlient/blob/master/LICENSE )
77
88A fast and modern graphql client designed with simplicity in mind.
@@ -20,65 +20,19 @@ pip install qlient
2020## Quick Start
2121
2222```` python
23- from qlient import Client
23+ from qlient import Client, GraphQLResponse
2424
25- client = Client(" https://api.spacex.land/graphql/ " )
25+ client = Client(" https://swapi-graphql.netlify.app/.netlify/functions/index " )
2626
27- res = client.query.launchesPast(
28- # spacex graphql input fields
29- find = {" mission_name" : " Starlink" },
30- limit = 5 ,
31- sort = " mission_name" ,
27+ res: GraphQLResponse = client.query.film(
28+ # swapi graphql input fields
29+ id = " ZmlsbXM6MQ==" ,
3230
3331 # qlient specific
34- _fields = [" mission_name " , " launch_success " , " launch_year " ]
32+ _fields = [" id " , " title " , " episodeID " ]
3533)
36- ````
37-
38- which sends the following query
39-
40- ``` gql
41- query launchesPast ($find : LaunchFind , $limit : Int , $sort : String ) {
42- launchesPast (find : $find , limit : $limit , sort : $sort ) {
43- mission_name
44- launch_success
45- launch_year
46- }
47- }
48- ```
49-
50- to the server and return this body:
5134
52- ```` json
53- {
54- "data" : {
55- "launchesPast" : [
56- {
57- "mission_name" : " Paz / Starlink Demo" ,
58- "launch_success" : true ,
59- "launch_year" : " 2018"
60- },
61- {
62- "mission_name" : " Starlink 1" ,
63- "launch_success" : true ,
64- "launch_year" : " 2019"
65- },
66- {
67- "mission_name" : " Starlink 2" ,
68- "launch_success" : true ,
69- "launch_year" : " 2020"
70- },
71- {
72- "mission_name" : " Starlink 3" ,
73- "launch_success" : true ,
74- "launch_year" : " 2020"
75- },
76- {
77- "mission_name" : " Starlink 4" ,
78- "launch_success" : true ,
79- "launch_year" : " 2020"
80- }
81- ]
82- }
83- }
84- ````
35+ print (res.query) # query film($id: ID) { film(id: $id) { id title episodeID } }
36+ print (res.variables) # {'id': 'ZmlsbXM6MQ=='}
37+ print (res.data) # {'film': {'id': 'ZmlsbXM6MQ==', 'title': 'A New Hope', 'episodeID': 4}}
38+ ````
0 commit comments