AniLink - v3.0.0
    Preparing search index...

    Function invalidateAfterMutation

    • Invalidates the cached reads a successful non-GET request may have changed, so a read-after-write sequence refetches instead of serving the pre-mutation entry for the rest of the TTL.

      Two shapes are handled:

      • A REST write (POST/PUT/PATCH/DELETE on the REST protocol) drops the cached GET entries of the mutated resource, derived from the request URL (see deriveMutationCachePrefix).
      • A GraphQL mutation document whose root field is mapped in MUTATION_ROOT_FIELD_INVALIDATION drops only the cached GraphQL queries at the endpoint whose root field the mutation can change: a SaveMediaListEntry flushes MediaList/MediaListCollection/Page queries but leaves a cached Staff query warm. Cached queries whose document cannot be attributed to a single root field are dropped by every scoped invalidation (see ResponseCache.deleteRootFieldsForUrl), fail-closed. A mutation not in the map (including any future upstream mutation) falls back to the conservative whole-endpoint invalidation (see ResponseCache.deleteAllForUrl), so an unmapped mutation can never under-invalidate.

      The write-ness decision comes from the request's own shape, the method, protocol, and document, never from whether the request was cache-keyed. A cacheable read can legitimately fail to be cache-keyed (the fail-closed path: credential headers the cache key does not capture), and such a read must never be mistaken for a mutation and wipe the endpoint's entries.

      Parameters

      • cache: ResponseCache | undefined

        The configured response cache, or undefined when the request ran cache-less; nothing is invalidated.

      • method: string

        The HTTP method of the completed request.

      • url: string

        The URL of the completed request.

      • data: string | object | undefined

        The request body, when present; distinguishes a GraphQL mutation document from a REST write.

      • isRestCall: boolean

        Whether the call resolved to the REST protocol.

      Returns void