From 2fc808e977eb94d3c3ac2fc3adc87d88e02c4cbd Mon Sep 17 00:00:00 2001 From: Guangya Liu Date: Tue, 6 Aug 2024 10:28:54 -0400 Subject: [PATCH] graphql (#190) --- graphql-example/graphql-github.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 graphql-example/graphql-github.py diff --git a/graphql-example/graphql-github.py b/graphql-example/graphql-github.py new file mode 100644 index 0000000..15e1e34 --- /dev/null +++ b/graphql-example/graphql-github.py @@ -0,0 +1,26 @@ +from dotenv import load_dotenv +load_dotenv() + +from graphqlclient import GraphQLClient + +# 创建一个 GraphQL 客户端实例 +client = GraphQLClient('https://api.github.com/graphql') + +# 设置你的 GitHub 个人访问令牌 +client.inject_token('Bearer xxx') + +# 定义一个 GraphQL 查询 +query = ''' +{ + viewer { + login + name + } +} +''' + +# 发送查询请求 +response = client.execute(query) + +# 打印响应 +print(response)