gql.transport
- class gql.transport.transport.Transport
Bases:
ABC- close()
Close the transport
This method doesn’t have to be implemented unless the transport would benefit from it. This is currently used by the RequestsHTTPTransport transport to close the session’s connection pool.
- connect()
Establish a session with the transport.
- abstractmethod execute(request: GraphQLRequest, *args: Any, **kwargs: Any) ExecutionResult
Execute GraphQL query.
Execute the provided request for either a remote or local GraphQL Schema.
- Parameters:
request – GraphQL request as a GraphQLRequest object.
- Returns:
ExecutionResult
- execute_batch(reqs: List[GraphQLRequest], *args: Any, **kwargs: Any) List[ExecutionResult]
Execute multiple GraphQL requests in a batch.
Execute the provided requests for either a remote or local GraphQL Schema.
- Parameters:
reqs – GraphQL requests as a list of GraphQLRequest objects.
- Returns:
a list of ExecutionResult objects
- class gql.transport.async_transport.AsyncTransport
Bases:
ABC- abstractmethod async close()
Coroutine used to Close an established connection
- abstractmethod async connect()
Coroutine used to create a connection to the specified address
- abstractmethod async execute(request: GraphQLRequest) ExecutionResult
Execute the provided request for either a remote or local GraphQL Schema.
- async execute_batch(reqs: List[GraphQLRequest], *args: Any, **kwargs: Any) List[ExecutionResult]
Execute multiple GraphQL requests in a batch.
Execute the provided requests for either a remote or local GraphQL Schema.
- Parameters:
reqs – GraphQL requests as a list of GraphQLRequest objects.
- Returns:
a list of ExecutionResult objects
- abstractmethod subscribe(request: GraphQLRequest) AsyncGenerator[ExecutionResult, None]
Send a query and receive the results using an async generator
The query can be a graphql query, mutation or subscription
The results are sent as an ExecutionResult object
- class gql.transport.local_schema.LocalSchemaTransport(schema: GraphQLSchema)
Bases:
AsyncTransportA transport for executing GraphQL queries against a local schema.
- __init__(schema: GraphQLSchema)
Initialize the transport with the given local schema.
- Parameters:
schema – Local schema as GraphQLSchema object
- async close()
No close needed on local transport
- async connect()
No connection needed on local transport
- async execute(request: GraphQLRequest, *args: Any, **kwargs: Any) ExecutionResult
Execute the provided request for on a local GraphQL Schema.
- async execute_batch(reqs: List[GraphQLRequest], *args: Any, **kwargs: Any) List[ExecutionResult]
Execute multiple GraphQL requests in a batch.
Execute the provided requests for either a remote or local GraphQL Schema.
- Parameters:
reqs – GraphQL requests as a list of GraphQLRequest objects.
- Returns:
a list of ExecutionResult objects
- async subscribe(request: GraphQLRequest, *args: Any, **kwargs: Any) AsyncGenerator[ExecutionResult, None]
Send a subscription and receive the results using an async generator
The results are sent as an ExecutionResult object