Skip to content

Instantly share code, notes, and snippets.

@ruizjme
Created November 7, 2018 12:34
Show Gist options
  • Save ruizjme/ef1c944dbe737cb49053e9e0084531ff to your computer and use it in GitHub Desktop.
Save ruizjme/ef1c944dbe737cb49053e9e0084531ff to your computer and use it in GitHub Desktop.
GraphQL crawl schema
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