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.
- abstract execute(document: DocumentNode, *args, **kwargs) ExecutionResult
Execute GraphQL query.
Execute the provided document AST for either a remote or local GraphQL Schema.
- Parameters:
document – GraphQL query as AST Node or Document object.
- Returns:
ExecutionResult
- execute_batch(reqs: List[GraphQLRequest], *args, **kwargs) 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
- abstract async close()
Coroutine used to Close an established connection
- abstract async connect()
Coroutine used to create a connection to the specified address
- abstract async execute(document: DocumentNode, variable_values: Dict[str, Any] | None = None, operation_name: str | None = None) ExecutionResult
Execute the provided document AST for either a remote or local GraphQL Schema.
- abstract subscribe(document: DocumentNode, variable_values: Dict[str, Any] | None = None, operation_name: str | None = None) 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:
AsyncTransport
A 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(document: DocumentNode, *args, **kwargs) ExecutionResult
Execute the provided document AST for on a local GraphQL Schema.
- async subscribe(document: DocumentNode, *args, **kwargs) AsyncGenerator[ExecutionResult, None]
Send a subscription and receive the results using an async generator
The results are sent as an ExecutionResult object