ds_provider_xledger_py_lib.utils.graphql¶
File: graphql.py
Region: ds_provider_xledger_py_lib/utils
Description¶
Helpers for normalizing GraphQL responses and errors.
Attributes¶
Functions¶
|
Raise typed DS exceptions for GraphQL payload errors. |
|
Map GraphQL payload errors to typed Xledger dataset exceptions. |
|
Instantiate an exception with explicit message and optional status code. |
|
Extract message/code metadata from a GraphQL error object. |
|
Best-effort extraction of HTTP-like status code from GraphQL error. |
Module Contents¶
- ds_provider_xledger_py_lib.utils.graphql.logger¶
- ds_provider_xledger_py_lib.utils.graphql.raise_for_graphql_errors(*, body: Any) dict[str, Any][source]¶
Raise typed DS exceptions for GraphQL payload errors.
GraphQL servers may return HTTP 200 while reporting failures under an
errorsfield in the response payload.- Parameters:
body – The GraphQL response body to inspect.
- Returns:
The original GraphQL response body when no error is present.
- ds_provider_xledger_py_lib.utils.graphql.map_graphql_errors_to_exception(*, errors: list[Any]) Exception[source]¶
Map GraphQL payload errors to typed Xledger dataset exceptions.
- Parameters:
errors – The GraphQL errors to map to exceptions.
- Returns:
The mapped exception.
- ds_provider_xledger_py_lib.utils.graphql._build_exception(exc_cls: type[Exception], *, message: str | None = None, status_code: int | None = None) Exception[source]¶
Instantiate an exception with explicit message and optional status code.
- Parameters:
exc_cls – The exception class to instantiate.
message – Optional message to include in the exception.
status_code – Optional HTTP-like status code. When omitted, the exception class handles its own default status behavior.