GitHub

client_error

API reference for client_error.

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

AttributeTypeDescription
GRAPHQL_ERRORStructSchema[GraphQLError, Never, Never]

The schema of a GraphQLError.

REASONUnionSchema[ResponseError | TransportError | EncodeError | DecodeError | PaginationError, Mapping[str, object], Never, Never]

The schema of every reason.

Types

TypeDefinitionDescription
Reasontype Reason = ResponseError | TransportError | EncodeError | DecodeError | PaginationError

Classes

Functions

is_fatal_close_code

is_fatal_close_code(code) -> 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.

ParameterTypeDescription
codeint

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_CODES

parse_retry_after_header

parse_retry_after_header(value, now_millis) -> Duration | None

A Retry-After value (whole seconds or an HTTP date) as a delay from now_millis; anything else is None.

ParameterTypeDescription
valuestr | None
now_millisfloat

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