-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |