kirjava.client

Contains the Client class itself.

class kirjava.client.Client(url)[source]

A GraphQL client. This is the object which sends requests to the GraphQL server.

The URL that serves the GraphQL content is given on creating the Client.

Parameters:
  • url (str) – The URL of the GraphQL server to interact with.

  • headers (dict) – Any additional HTTP headers.

execute(message, method='POST', variables=None, retries=0, retry_statuses=None)[source]

Sends a request to the GraphQL server.

Parameters:
  • message (str) – The query to make.

  • method (str) – By default, POST requests are sent, but this can be overriden here.

  • variables (dict) – Any GraphQL variables can be passed here.

  • retries (int) – The number of times to retry on failure.

  • retry_statuses (list) – The HTTP statuses to retry on.

Return type:

dict

property headers

The HTTP headers that will be sent with every request.

Return type:

dict

property history

The queries sent, most recent first.

Return type:

tuple

request_with_retries(operation, headers, files=None, method='POST', retries=0, retry_statuses=None)[source]

Sends a GraphQL request, retrying if necessary the specified number of times.

Parameters:
  • operation (str) – The GraphQL operation to send.

  • headers (dict) – The HTTP headers to send.

  • files (dict) – The files to send.

  • method (str) – The HTTP method to use.

  • retries (int) – The number of times to retry.

  • retry_statuses (list) – The HTTP statuses to retry on.

Return type:

requests.Response

property url

The URL of the GraphQL server to interact with.

Return type:

str