kirjava.utilities

Useful functions.

kirjava.utilities.create_response_error_message(response)[source]

Works out what to say about a response that isn’t JSON.

Parameters:

response – The HTTP response object.

Return type:

str

kirjava.utilities.execute(url, *args, headers=None, **kwargs)[source]

Sends a GraphQL request without the user haveing to make a dedicated Client object.

Parameters:
  • url (str) – the URL to send to.

  • message (str) – The query to make.

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

  • headers (dict) – Any additional HTTP headers.

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

Return type:

dict

kirjava.utilities.files_to_map(files)[source]

Takes a files dict and creates the map dict needed by the GraphQL file upload spec.

Parameters:

files (dict) – the files dict.

Return type:

dict

kirjava.utilities.get_files_from_variables(variables)[source]

Takes a variables objects and looks to see if any of the values are file objects which need to be sent separately.

Parameters:

variables (dict) – the variables to inspect, or None.

Returns:

(variables, files)

kirjava.utilities.pack_files(files)[source]

Takes a files dict and packs them into a HTTP sendable form.

Parameters:

files (dict) – the files dict.

Return type:

dict