AniLink - v2.0.0
    Preparing search index...

    Function requireVariables

    • Enforces the variable requirements of an AniList operation.

      AniList rejects several query operations at runtime with messages such as "The Media query requires at least 1 argument." even though the GraphQL schema declares every argument as optional. This helper lets each operation describe its real contract so callers fail fast with a local AniLinkValidationError instead of a remote 400.

      A variable satisfies a requirement when it is present with a value other than undefined and null. Requirements are expressed as:

      • "one": at least one variable must be set.
      • "all": every listed variable must be set.
      • "any": at least one of the listed variables must be set.
      • "notOnly": at least one variable must be set, and at least one set variable must not appear in names.

      Parameters

      • variables: object

        The variables the caller passed to the operation.

      • requirements:
            | { kind: "one" }
            | { kind: "all"; names: readonly string[] }
            | { kind: "any"; names: readonly string[] }
            | { kind: "notOnly"; names: readonly string[] }

        The requirement description for the operation.

      • message: string

        The error message describing what the operation needs.

      Returns void

      Nothing when the requirement is satisfied.

      An AniLinkValidationError when the requirements are not met.