This transport uses the httpx library and allows you to send GraphQL queries using the HTTP protocol.
Reference: gql.transport.httpx.HTTPXAsyncTransport
Note
GraphQL subscriptions are not supported on the HTTP transport. For subscriptions you should use the websockets transport <websockets_transport>
.
../code_examples/httpx_async.py
There are multiple ways to authenticate depending on the server configuration.
- Using HTTP Headers
transport = HTTPXAsyncTransport(
url='https://SERVER_URL:SERVER_PORT/graphql',
headers={'Authorization': 'token'}
)
- Using HTTP Cookies
You can manually set the cookies which will be sent with each connection:
transport = HTTPXAsyncTransport(url=url, cookies={"cookie1": "val1"})