In order to make HTTP requests from Python, we are going to use the pip installable requests package:
import requests
Then, we need to define the request parameters:
query = """
{
User(login: "me") {
login
}
}
"""
data = {
"query": query,
}
Finally, we can post the request using a JSON-encoded payload:
r = requests.post(
"http://localhost:4001/graphql",
json=data,
headers={
}
)
print(r.json())
The result is as follows:
{'data': {}}