Execute GraphQl query

async AsyncCogniteClient.data_modeling.graphql.query(
id: DataModelId | tuple[str, str] | tuple[str, str, str],
query: str,
variables: dict[str, Any] | None = None,
) dict[str, Any]

Execute a GraphQl query against a given data model.

Parameters:
  • id (DataModelIdentifier) – The data model to query.

  • query (str) – The query to issue.

  • variables (dict[str, Any] | None) – An optional dict of variables to pass to the query.

Returns:

The query result

Return type:

dict[str, Any]

Examples

Execute a graphql query against a given data model:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> res = client.data_modeling.graphql.query(
...     id=("mySpace", "myDataModel", "v1"),
...     query="listThings { items { thingProperty } }",
... )