一个简单的graphql客户端,它还支持文件上传

simple-graphql-client的Python项目详细描述


简单GraphQL客户端

安装

客户端在PyPI上可用:

  • $ pip install simple-graphql-client

示例

执行查询

fromsimple_graphql_clientimportGraphQLClientheaders={'Authorization':'Bearer ...'}client=GraphQLClient("https://...",headers=headers)query="..."variables={...}data=client.query(query=query,variables=variables)

使用单个文件执行查询

注意:有关信息,请访问:https://github.com/jaydenseric/graphql-multipart-request-spec

^{pr2}$

使用多个文件执行查询

fromsimple_graphql_clientimportGraphQLClientclient=GraphQLClient("https://...")query="..."filenames=["...","..."]files=[]variables={...'files':[None,None]...}fori,filenameinenumerate(filenames):variable='files.{}'.format(i)files.append((variable,(filename,open(filename,"rb"))))response=client.query_with_files(query=query,variables=variables,files=files)

设置查询特定的头

此参数将覆盖可在GraphQLClient中设置的默认标头

response=client.query(query=query,variables=variables,files=files,headers=headers)response=client.query_with_files(query=query,variables=variables,files=files,headers=headers)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
图形Java仿射变换以旋转通用路径   IntelliJ IDEA中的java代码标记为编译器错误,在Eclipse中可以正常工作   java ArrayList的containsAll返回了错误的值   如何在安卓中的片段活动中添加java代码   java通过使用netbeans调用jbutton,将带有行的jbutton添加到jtable中   java在更新arrayAdapter/listView之前更新最终列表   java如何在另一个项目中导入包含AspectJ方面和注释的项目   为什么我的java布尔测试总是失败?   Eclipse中的java自动激活   在Bluetooth for Java(更具体地说是Android)之上是否有TCP/IP协议栈实现?   java Android Studio通过intent传递ArrayList并填充ListView