用于Python2.7的简单GraphQL客户端+
graphqlclient的Python项目详细描述
python graphql客户端
用于Python2.7+的简单GraphQL客户端
安装
pip install graphqlclient
用法
fromgraphqlclientimportGraphQLClientclient=GraphQLClient('http://graphql-swapi.parseapp.com/')result=client.execute('''{ allFilms { films { title } }}''')print(result)
授权
可以使用客户端的inject_token
方法将授权令牌添加到请求:
client.inject_token('very-long-and-secure-token')
默认为http头名称Authorization
。
令牌的可选http头名称可以通过传入可选头名称来设置,例如用于x-api-key
:
client.inject_token('very-long-and-secure-token','x-api-key')