subgrounds.client module#

Small module containing low level functions related to sending GraphQL http requests.

subgrounds.client.get_schema(url, headers)#

Runs the introspection query on the GraphQL API served localed at url and returns the result. In case of errors, an exception containing the error message is thrown.

Parameters:

url (str) -- The url of the GraphQL API

Raises:
  • HttpError -- If the request response resulted in an error

  • ServerError -- If server responds back non-json content

  • GraphQLError -- If the GraphQL query failed or other grapql server errors

Returns:

The GraphQL API's schema in JSON

Return type:

dict[str, Any]

subgrounds.client.query(url, query_str, variables={}, headers={})#

Executes the GraphQL query query_str with variables variables against the API served at url and returns the response data. In case of errors, an exception containing the error message is thrown.

Parameters:
  • url (str) -- The URL of the GraphQL API

  • query_str (str) -- The GraphQL query string

  • variables (dict[str, Any], optional) -- Variables for the GraphQL query. Defaults to {}.

Raises:
  • HttpError -- If the request response resulted in an error

  • ServerError -- If server responds back non-json content

  • GraphQLError -- If the GraphQL query failed or other grapql server errors

Returns:

Response data

Return type:

dict[str, Any]