ds_protocol_graphql_py_lib.utils ================================ .. py:module:: ds_protocol_graphql_py_lib.utils .. autoapi-nested-parse:: **File:** ``__init__.py`` **Region:** ``ds_protocol_graphql_py_lib/utils`` Shared helpers for the GraphQL protocol. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/ds_protocol_graphql_py_lib/utils/json_utils/index Functions --------- .. autoapisummary:: ds_protocol_graphql_py_lib.utils.get_list ds_protocol_graphql_py_lib.utils.get_path Package Contents ---------------- .. py:function:: get_list(data: Any, path: str) -> list[Any] Read a list at ``path``. A ``null`` list is an empty list: GraphQL APIs commonly return ``null`` instead of ``[]`` for an empty nullable list (Visma Business NXT does). A missing path, including one whose parent is ``null``, is an error, so a typo in the path fails loudly instead of reading as "no rows". :param data: Parsed JSON value. :param path: Dotted path to a list. :returns: The list at ``path``, or ``[]`` when the value there is ``null``. :raises ValueError: If the path is missing. :raises TypeError: If the path resolves to a non-list value. .. py:function:: get_path(data: Any, path: str) -> Any Read a value via dotted path. :param data: Parsed JSON value. :param path: Dotted path; ``$`` or ``""`` returns ``data`` itself. List segments are integer indexes; negative indexes count from the end. :returns: The value at ``path``, or ``None`` when any segment is missing or a list index is out of range (e.g. ``-1`` on an empty list).