subgrounds.client module

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

subgrounds.client.get_schema(url)

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

Exception -- In case of GraphQL server error

Returns

The GraphQL API's schema in JSON

Return type

dict[str, Any]

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

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

Exception -- GraphQL error

Returns

Response data

Return type

dict[str, Any]