AniLink - v3.0.0
    Preparing search index...

    Function unwrapGraphQLResponse

    • Unwraps a GraphQL response envelope.

      This is the tolerant wrapper around unwrapSingleRootField used by the request pipeline. Documents with exactly one root field resolve to the bare field value; documents with multiple root fields (or none) are returned as the full envelope unchanged. All shipped operations use one root field, so typed operations return the bare value. Custom documents with multiple root fields return the envelope.

      An envelope carrying a non-empty errors array (an HTTP 200 GraphQL failure) throws an AniLinkGraphQLError instead of returning data, unless options.allowPartialData is set and the envelope also carries a non-null data object, in which case the data is returned and the error entries are reported through options.onPartialData with the same AniLinkGraphQLError the strict mode would have thrown.

      Type Parameters

      • T

      Parameters

      • response: unknown

        The full GraphQL response envelope.

      • Optionalheaders: Record<string, unknown>

        The response headers, when available, so rate-limit and content-type metadata from the HTTP 200 envelope are preserved on the thrown AniLinkGraphQLError (AniList returns x-ratelimit-* headers even on envelopes carrying GraphQL-level errors).

      • Optionaloptions: UnwrapOptions

        Partial-success controls; see UnwrapOptions.

      Returns T

      The unwrapped single-root-field value, or the envelope as-is.

      An AniLinkGraphQLError when the envelope carries GraphQL errors and either no allowPartialData opt-in applies or no usable data object accompanies them.