diff --git a/my_flask_graphql_app/client.py b/my_flask_graphql_app/client.py new file mode 100644 index 0000000..d5eab7b --- /dev/null +++ b/my_flask_graphql_app/client.py @@ -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()