-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgql_user.py
More file actions
48 lines (36 loc) · 1.14 KB
/
gql_user.py
File metadata and controls
48 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# vim: set expandtab ts=4 sw=4 filetype=python fileencoding=utf8:
import os
import pprint
import gql
import requests
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
if __name__ == "__main__":
if "GITHUB_TOKEN" not in os.environ:
raise Exception("Sorry, I need a GITHUB TOKEN!")
else:
sample_transport=RequestsHTTPTransport(
url="https://api.github.com/graphql",
use_json=True,
headers={
"Authorization": "bearer {GITHUB_TOKEN}".format(**os.environ),
"Content-Type": "application/json",
},
verify=True
)
client = Client(
transport=sample_transport,
fetch_schema_from_transport=True,
)
query = gql('''
query getasdasfdUserData($github_user: String!) {
user(login: $github_user) {
login
company
}
}
''')
query_vars = {"github_user":"bormesh"}
x = client.execute(query, query_vars)
print(type(x))
pprint.pprint(x)