Created
November 7, 2018 12:34
-
-
Save ruizjme/ef1c944dbe737cb49053e9e0084531ff to your computer and use it in GitHub Desktop.
GraphQL crawl schema
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
def graphql_query(payload): | |
query = str(payload).replace("'",'%22') | |
r = requests.get("https://example.com/graphql?query={}".format(query)) | |
return r.json() | |
payload = "{__schema{types{name}}}" | |
r = graphql_query(payload) | |
for t in [i['name'] for i in r['data']['__schema']['types']]: | |
print(t) | |
payload = "{__type(name:'"+t+"'){name,fields{name,type{name,kind}}}}" | |
r = graphql_query(payload) | |
pprint.pprint(r) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment