Skip to content

Commit

Permalink
graphql (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyliu513 committed Aug 6, 2024
1 parent 16eb4a7 commit 2fc808e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions graphql-example/graphql-github.py
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)

0 comments on commit 2fc808e

Please sign in to comment.