Skip to content

Add a first-class wildcard/partial-invalidation API to the query cache #35

Description

@Ehonrie

Difficulty: Advanced
Category: Feature

Context: invalidateQuery today only supports exact-prefix matching over the ordered QueryKey tuple. There's no way to invalidate "all proposal queries for any project" without knowing the exact prefix, nor to invalidate by a predicate (e.g., "any query whose 2nd segment is this member address, regardless of position"). Several call sites likely reimplement ad-hoc multi-key invalidation loops as a workaround.

// dapp/src/service/cache/cacheStore.ts
export function invalidateQueryWhere(
  predicate: (queryKey: import("./cacheTypes").QueryKey) => boolean,
): void {
  // !todo: Add a predicate-based invalidation entry point alongside the existing
  //        prefix-based invalidateQuery, sharing the same underlying iteration/marking logic.
  // !todo: Must compose with a trie-based index if one exists — avoid reintroducing a
  //        full-registry scan as the ONLY option for non-prefix invalidation patterns.
  // !todo: Must emit the same isStale/isFetching/expiresAt transition as invalidateQuery
  //        for every matched entry, for hook-layer consistency.
  throw new Error("Not implemented");
}

What contributors need to know:

  • Problem: cacheStore.ts only exports prefix-based invalidateQuery (cacheStore.ts:77-93).
  • Related code: cacheKeys.ts (existing QueryKey conventions), cacheHooks.ts.
  • Suggested approach: grep call sites across dapp/src/service for places that loop calling invalidateQuery multiple times to approximate a predicate match — that's the evidence this feature is actually needed.
  • Acceptance criteria: at least one existing multi-call invalidation workaround in the codebase replaced with a single invalidateQueryWhere call; new unit tests for predicate matching.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26advancedDifficulty: AdvancedfeatureComplex feature implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions