Skip to content

Add queryHash to QueryFunctionContext#1

Merged
ElliotChong-MS merged 3 commits intopatch-1from
copilot/add-queryhash-to-queryfunctioncontext
Oct 25, 2025
Merged

Add queryHash to QueryFunctionContext#1
ElliotChong-MS merged 3 commits intopatch-1from
copilot/add-queryhash-to-queryfunctioncontext

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 25, 2025

The QueryFunctionContext type already included queryHash: string, but the property was not populated when creating context objects, causing TypeScript compilation errors.

Changes

  • Implementation: Populate queryHash from Query.queryHash in context objects

    • query.ts: Added queryHash: this.queryHash to query function context
    • infiniteQueryBehavior.ts: Added queryHash: query.queryHash to infinite query contexts (2 locations)
  • Tests: Updated context assertions to expect queryHash property

    • Added explicit test verifying queryHash matches hashQueryKeyByOptions(key)
    • Updated infinite query behavior tests and type tests
  • Documentation: Added queryHash to QueryFunctionContext property list in query functions guide

Example

const queryFn = (context: QueryFunctionContext) => {
  console.log(context.queryHash); // Now populated: '["todos",{"status":"active"}]'
  return fetch(`/api/data?hash=${context.queryHash}`);
};

The hash is computed from the query key and serves as a stable, unique identifier for the query across the cache.

Original prompt

Add queryHash: string to the QueryFunctionContext type. Use the Query's queryHash property to populate the value. Ensure appropriate docs, tests, etc. are updated throughout the repository.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 25, 2025 02:14
Co-authored-by: ElliotChong-MS <77078627+ElliotChong-MS@users.noreply.github.com>
Co-authored-by: ElliotChong-MS <77078627+ElliotChong-MS@users.noreply.github.com>
Copilot AI changed the title [WIP] Add queryHash to QueryFunctionContext type Add queryHash to QueryFunctionContext Oct 25, 2025
Copilot AI requested a review from ElliotChong-MS October 25, 2025 02:24
@ElliotChong-MS
Copy link
Copy Markdown
Owner

@copilot Update the PR description to be written as if the change to QueryFunctionContext was included in the changeset.

Copilot AI requested a review from ElliotChong-MS October 25, 2025 14:42
@ElliotChong-MS ElliotChong-MS marked this pull request as ready for review October 25, 2025 14:42
@ElliotChong-MS ElliotChong-MS merged commit 41e5995 into patch-1 Oct 25, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants