# gql.transport.httpx

class gql.transport.httpx.HTTPXTransport(url: str | ~httpx.URL, json_serialize: ~typing.Callable = <function dumps>, json_deserialize: ~typing.Callable = <function loads>, **kwargs: ~typing.Any)

  Bases: `Transport`, `_HTTPXTransport`

  Sync Transport used to execute GraphQL queries on remote servers.

  The transport uses the httpx library to send HTTP POST requests.

  client: Client | None = None
  connect()

    Establish a session with the transport.

  execute(request: GraphQLRequest, *, extra_args: Dict[str, Any] | None = None, upload_files: bool = False) → ExecutionResult

    Execute GraphQL query.

    Execute the provided request against the configured remote server. This uses the httpx library to perform a HTTP POST request to the remote server.

    Parameters:

      - request – GraphQL request as a `GraphQLRequest` object.

      - extra_args – additional arguments to send to the httpx post method

      - upload_files – Set to True if you want to put files in the variable values

    Returns:

      The result of execution. data is the result of executing the query, errors is null if no errors occurred, and is a non-empty array if an error occurred.

  execute_batch(reqs: List[GraphQLRequest], extra_args: Dict[str, Any] | None = None) → List[ExecutionResult]

    Execute multiple GraphQL requests in a batch.

    Don’t call this coroutine directly on the transport, instead use `execute_batch` on a client or a session.

    Parameters:

      - reqs – GraphQL requests as a list of GraphQLRequest objects.

      - extra_args – additional arguments to send to the httpx post method

    Returns:

      A list of results of execution. For every result data is the result of executing the query, errors is null if no errors occurred, and is a non-empty array if an error occurred.

  close()

    Closing the transport by closing the inner session

  __init__(url: str | ~httpx.URL, json_serialize: ~typing.Callable = <function dumps>, json_deserialize: ~typing.Callable = <function loads>, **kwargs: ~typing.Any)

    Initialize the transport with the given httpx parameters.

    Parameters:

      - url – The GraphQL server URL. Example: ‘https://server.com:PORT/path’.

      - json_serialize – Json serializer callable. By default json.dumps() function.

      - json_deserialize – Json deserializer callable. By default json.loads() function.

      - kwargs – Extra args passed to the httpx client.

  file_classes: Tuple[Type[Any], ...] = (<class 'io.IOBase'>,)
  response_headers: Headers | None = None

class gql.transport.httpx.HTTPXAsyncTransport(url: str | ~httpx.URL, json_serialize: ~typing.Callable = <function dumps>, json_deserialize: ~typing.Callable = <function loads>, **kwargs: ~typing.Any)

  Bases: `AsyncTransport`, `_HTTPXTransport`

  Async Transport used to execute GraphQL queries on remote servers.

  The transport uses the httpx library with anyio.

  client: AsyncClient | None = None
  async connect()

    Coroutine used to create a connection to the specified address

  async execute(request: GraphQLRequest, *, extra_args: Dict[str, Any] | None = None, upload_files: bool = False) → ExecutionResult

    Execute GraphQL query.

    Execute the provided request against the configured remote server. This uses the httpx library to perform a HTTP POST request asynchronously to the remote server.

    Parameters:

      - request – GraphQL request as a `GraphQLRequest` object.

      - extra_args – additional arguments to send to the httpx post method

      - upload_files – Set to True if you want to put files in the variable values

    Returns:

      The result of execution. data is the result of executing the query, errors is null if no errors occurred, and is a non-empty array if an error occurred.

  async execute_batch(reqs: List[GraphQLRequest], extra_args: Dict[str, Any] | None = None) → List[ExecutionResult]

    Execute multiple GraphQL requests in a batch.

    Don’t call this coroutine directly on the transport, instead use `execute_batch` on a client or a session.

    Parameters:

      - reqs – GraphQL requests as a list of GraphQLRequest objects.

      - extra_args – additional arguments to send to the httpx post method

    Returns:

      A list of results of execution. For every result data is the result of executing the query, errors is null if no errors occurred, and is a non-empty array if an error occurred.

  async close()

    Closing the transport by closing the inner session

  __init__(url: str | ~httpx.URL, json_serialize: ~typing.Callable = <function dumps>, json_deserialize: ~typing.Callable = <function loads>, **kwargs: ~typing.Any)

    Initialize the transport with the given httpx parameters.

    Parameters:

      - url – The GraphQL server URL. Example: ‘https://server.com:PORT/path’.

      - json_serialize – Json serializer callable. By default json.dumps() function.

      - json_deserialize – Json deserializer callable. By default json.loads() function.

      - kwargs – Extra args passed to the httpx client.

  file_classes: Tuple[Type[Any], ...] = (<class 'io.IOBase'>,)
  response_headers: Headers | None = None