AniLink - v2.0.0
    Preparing search index...

    CustomRequest is a class representing a custom query or mutation by the user.

    Hierarchy (View Summary)

    Index
    • custom is a method that sends a custom query or mutation by the user.

      The response follows the same unwrapping rule as every other operation: a document with a single root field resolves to the bare field value, while a document with multiple root fields resolves to the full { data } envelope. Annotate T with the shape you expect — the bare value for single-root-field documents, or the envelope type itself when the document selects several root fields:

      const viewer = await aniLink.anilist.custom<{ id: number }>("query { Viewer { id } }");

      // Multi-root-field document: T is the full envelope.
      const both = await aniLink.anilist.custom<{ data: { Media: { id: number }; User: { id: number } } }>(
      "query { Media (id: 1) { id } User (id: 1) { id } }"
      );

      Type Parameters

      • T = unknown

      Parameters

      • query: string

        The GraphQL document to execute. It must declare a query or mutation operation.

      • variables: Record<string, unknown> = {}

        The variables for the document. This parameter is optional.

      • Optionaloptions: RequestOptions

        Optional per-request transport settings merged over the instance-level ones for this call only.

      Returns Promise<T>

      A promise that resolves to the unwrapped response data for single-root-field documents, or the full { data } envelope otherwise.

      An AniLinkValidationError when the query is empty or does not declare a query or mutation operation.

      An AniLinkError when the request fails.