AniLink - v2.0.0
    Preparing search index...

    Function unwrapSingleRootField

    • Unwraps the single root field of a GraphQL response envelope.

      The AniList API returns every operation's result inside a { data } envelope. For operations whose selection set has exactly one root field (for example User, Media, or MediaListCollection), this helper returns the bare field value. When the envelope carries zero or multiple root fields, or no data object at all, it returns undefined so callers can decide what to do with a document whose shape does not match the single-root-field contract.

      Type Parameters

      • T

      Parameters

      • response: unknown

        The full GraphQL response envelope.

      Returns T | undefined

      The bare root-field value, or undefined when the document does not have exactly one root field.