Python图形客户端
python-graphql-client的Python项目详细描述
Python-GraphQL客户端
Simple package for making requests to a graphql server.
安装
pip install python-graphql-client
使用
- 查询/变异
- 认购
frompython_graphql_clientimportGraphqlClient# Instantiate the client with a websocket endpoint.client=GraphqlClient(endpoint="wss://www.your-api.com/graphql")# Create the query string and variables required for the request.query=""" subscription onMessageAdded { messageAdded }"""# Asynchronous requestimportasyncioasyncio.run(client.subscribe(query=query,handle=print))# => {'data': {'messageAdded': 'Error omnis quis.'}}# => {'data': {'messageAdded': 'Enim asperiores omnis.'}}# => {'data': {'messageAdded': 'Unde ullam consequatur quam eius vel.'}}# ...
高级用法
禁用SSL验证
在实例化GraphqlClient
类时,设置关键字参数verify=False
ether。在
frompython_graphql_clientimportGraphqlClientclient=GraphqlClient(endpoint="wss://www.your-api.com/graphql",verify=False)
或者,您可以在调用execute
方法时设置它。在
frompython_graphql_clientimportGraphqlClientclient=GraphqlClient(endpoint="wss://www.your-api.com/graphql"client.execute(query="<Your Query>",verify=False)
自定义身份验证
fromrequests.authimportHTTPBasicAuthfrompython_graphql_clientimportGraphqlClientauth=HTTPBasicAuth('fake@example.com','not_a_real_password')client=GraphqlClient(endpoint="wss://www.your-api.com/graphql",auth=auth)
路线图
首先,我们将尝试使用Github项目板来列出当前的工作并更新即将到来的特性的优先级。在
贡献
阅读Contributing文档,了解向项目提交请求请求的详细过程。也可以看看我们的Code of Conduct。在
作者和确认
感谢@xkludge、@DaleSeo和@mattbullock启动这个项目。在
许可证
- 项目
标签: