Data Containers

GraphQLRequest

class aiographql.client.GraphQLRequest(query: str, operation: dataclasses.InitVar[str | None] = None, variables: dict[str, Any]=<factory>, validate: bool = True, headers: dict[str, str]=<factory>, codec: GraphQLCodec | None = None) None

GraphQL Request object that can be reused or used to store multiple named queries with default operationName`, *variables and header to use.

Parameters:
  • query (str) – GraphQL query string.

  • operation (InitVar) – Optional name of operation to use from the query.

  • variables (dict[str, Any]) – Variable dictionary pass with the query to the server.

  • validate (bool) – If True, the request query is validated against the latest available schema from the server.

  • headers (dict[str, str]) – Headers to use, in addition to client default headers when making the HTTP request.

  • codec (GraphQLCodec | None)

GraphQLResponse

class aiographql.client.GraphQLResponse(request: GraphQLRequest | str, headers: dataclasses.InitVar[dict[str, str] | None]=None, operation: dataclasses.InitVar[str | None] = None, variables: dataclasses.InitVar[dict[str, Any] | None]=None, codec: dataclasses.InitVar[GraphQLCodec | None] = None, json: dict[str, Any]=<factory>) None

GraphQL Response object wrapping response data and any errors. This object also contains the a copy of the GraphQLRequest that produced this response.

Parameters:
  • request (GraphQLRequest | str)

  • headers (dataclasses.InitVar[dict[str, str] | None])

  • operation (dataclasses.InitVar[str | None])

  • variables (dataclasses.InitVar[dict[str, Any] | None])

  • codec (dataclasses.InitVar[GraphQLCodec | None])

  • json (dict[str, Any])

property errors: list[GraphQLError]

A list of GraphQLError objects if server responded with query errors.

property data: dict[str, Any]

The data payload the server responded with.

property query: str

The query string used to produce this response.

data_as(result_type: type[T], path: str | None = None, codec: GraphQLCodec | None = None) T

Decode the response data into a Python object of the specified type.

Parameters:
  • result_type (type[TypeVar(T)]) – The type to decode the data into.

  • path (str | None) – An optional dot-separated path to the data to decode.

  • codec (GraphQLCodec | None) – An optional codec to use for decoding. If not provided, it’s retrieved from the request’s client if available.

Return type:

TypeVar(T)

GraphQLSubscriptionEvent

class aiographql.client.GraphQLSubscriptionEvent(request: GraphQLRequest | str, headers: dataclasses.InitVar[dict[str, str] | None]=None, operation: dataclasses.InitVar[str | None] = None, variables: dataclasses.InitVar[dict[str, typing.Any] | None]=None, codec: dataclasses.InitVar[aiographql.client.codec.GraphQLCodec | None] = None, json: dict[str, ~typing.Any]=<factory>, subscription_id: str | None = None) None

GraphQL subscription event wrapping the payload received from the server.

Parameters:
property id: str | None

The id of the event, if available.

property type: GraphQLSubscriptionEventType | None

The type of event (GraphQLSubscriptionEventType).

property payload: GraphQLResponse | str | None

The id of the subscription that generated this event.

GraphQLCodec

class aiographql.client.GraphQLCodec(*args, **kwargs)

DefaultGraphQLCodec

class aiographql.client.DefaultGraphQLCodec None

GraphQLError

class aiographql.client.GraphQLError(extensions: dict[str, ~typing.Any]=<factory>, locations: list[dict[str, int]] | None=None, message: str | None = None, path: list[str | int] | None = None) None

GraphQL error response object.

Parameters:
extensions: dict[str, Any]
locations: list[dict[str, int]] | None = None
message: str | None = None
path: list[str | int] | None = None
classmethod load(data: dict[str, Any]) T
Parameters:

data (dict[str, Any])

Return type:

TypeVar(T, bound= GraphQLError)