Configuring HTTP Transport¶
Custom HTTP Client Sessions¶
The client allows you to specify a aiohttp Client Session for use at various levels. Including per query and/or for all queries made by the client.
This can be done so by passing in the session when doing any of the following;
creating a client
aiographql.GraphQLClient(
endpoint="http://127.0.0.1:8080/v1/graphql", session=session
)
making a query
await client.query(
request=request, session=session
)
creating a subscription
await client.subscribe(
request=request, session=session
)
Using Behind SOCK Proxies¶
In order use via a socks proxy, you will need to custom connector, like the one provided by aiohttp-socks.
Here is an example code snippet using this library.
connector = aiohttp_socks.ProxyConnector(
proxy_type=aiohttp_socks.ProxyType.SOCKS5,
host="127.0.0.1",
port=1080,
rdns=True,
)
async with aiohttp.ClientSession(connector=connector) as session:
client = GraphQLClient(
endpoint="http://gql.example.com/v1/graphql", session=session
)
await client.query(request="query { city { name } }")