The errors of a GraphQL client (Effect's GraphQLClientError).
Every client method fails with a GraphQLClientError: the operation
that failed and a reason saying why. ResponseError is a response
with GraphQL errors; TransportError a response that never came or
was not GraphQL; EncodeError / DecodeError variables or data that
did not match their schemas; PaginationError cursor paging that could
not go on. is_retryable and retry_after read the reason.
Each error is a schema class, so errors round-trip through
S.encode_sync / S.decode_unknown_sync; headers encode as a plain
string record and retryAfter as milliseconds.
Values#
| Attribute | Type | Description |
|---|---|---|
GRAPHQL_ERROR | StructSchema[GraphQLError, Never, Never] | The schema of a |
REASON | UnionSchema[ResponseError | TransportError | EncodeError | DecodeError | PaginationError, Mapping[str, object], Never, Never] | The schema of every reason. |
Types#
| Type | Definition | Description |
|---|---|---|
Reason | type Reason = ResponseError | TransportError | EncodeError | DecodeError | PaginationError |
Classes#
Functions#
is_fatal_close_code#
is_fatal_close_code(code) -> boolA WebSocket close code that retrying cannot fix: every standard
1xxx code but 1000, 1001, 1005, 1006, 1012, 1013 and 1014, and the
graphql-ws codes 4400, 4401, 4403, 4406, 4409, 4429 and 4500.
| Parameter | Type | Description |
|---|---|---|
code | int |
Returns bool
def is_fatal_close_code(code: int) -> bool:
"""A WebSocket close code that retrying cannot fix: every standard
``1xxx`` code but 1000, 1001, 1005, 1006, 1012, 1013 and 1014, and the
graphql-ws codes 4400, 4401, 4403, 4406, 4409, 4429 and 4500."""
if 1000 <= code < 2000:
return code not in _RETRYABLE_STANDARD_CLOSE_CODES
return code in _FATAL_GRAPHQL_WS_CLOSE_CODESparse_retry_after_header#
parse_retry_after_header(value, now_millis) -> Duration | NoneA Retry-After value (whole seconds or an HTTP date) as a delay
from now_millis; anything else is None.
| Parameter | Type | Description |
|---|---|---|
value | str | None | |
now_millis | float |
Returns Duration | None
def parse_retry_after_header(value: str | None, now_millis: float) -> Duration | None:
"""A ``Retry-After`` value (whole seconds or an HTTP date) as a delay
from ``now_millis``; anything else is ``None``."""
if value is None:
return None
parsed = parse_retry_after(value)
return retry_after_delay(parsed.value, now_millis) if isinstance(parsed, Ok) else None