Skip to content

Commit

Permalink
add client (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyliu513 committed Aug 6, 2024
1 parent ffd8b00 commit 6371d09
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions my_flask_graphql_app/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import requests

def query_all_users():
url = 'http://127.0.0.1:5000/graphql'
query = """
{
allUsers {
edges {
node {
id
username
email
}
}
}
}
"""
response = requests.post(url, json={'query': query})
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Query failed to run with a {response.status_code}.")

def main():
try:
result = query_all_users()
print("Query result:")
print(result)
except Exception as e:
print(e)

if __name__ == '__main__':
main()

0 comments on commit 6371d09

Please sign in to comment.