Skip to content

Add refetch on changed fn #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged

Add refetch on changed fn #85

merged 1 commit into from
Apr 8, 2025

Conversation

k-ode
Copy link
Contributor

@k-ode k-ode commented Mar 18, 2025

No description provided.

@k-ode k-ode force-pushed the feature/refetch-on-changed-fn branch from cd6461d to 6291eb8 Compare March 18, 2025 20:39
@k-ode k-ode requested a review from Copilot March 18, 2025 21:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for using a functional refetchOnChanged option that triggers a query refetch when the request parameters change. It also updates the type definitions and query observer logic to accommodate the new behavior and adjusts the ItemQuery model to include an additional field.

  • Adds a new test to verify the refetchOnChanged functionality.
  • Updates hooks.ts to accept a functional form for refetchOnChanged.
  • Modifies MstQueryHandler.ts to use a new isReenabled flag for improved refetch logic.
  • Adjusts the ItemQuery model to include an additional id2 field.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

File Description
packages/mst-query/tests/mstQuery.test.tsx Introduced a new test for the refetchOnChanged function behavior
packages/mst-query/src/hooks.ts Updated type definitions and error messaging for refetchOnChanged
packages/mst-query/src/MstQueryHandler.ts Modified observer and query logic to incorporate an isReenabled flag for refetching
packages/mst-query/tests/models/ItemQuery.ts Extended the request model to include an additional id2 field
Files not reviewed (2)
  • packages/mst-query/package-lock.json: Language not supported
  • packages/mst-query/package.json: Language not supported
Comments suppressed due to low confidence (2)

packages/mst-query/src/MstQueryHandler.ts:297

  • Changing the condition from checking 'refetchOnChanged === "none"' to 'options.isReenabled' alters the behavior for not-initialized queries. Please verify that this new condition correctly represents the intended logic for triggering a new query on re-enabled requests.
if (notInitialized && options.isReenabled) {

packages/mst-query/src/MstQueryHandler.ts:86

  • Ensure that the 'isReenabled' flag is appropriately reset on subsequent options updates to avoid unintended persistence and unexpected query behavior.
if (!this.options.enabled && options.enabled) {

@k-ode k-ode merged commit e7ebcdd into main Apr 8, 2025
1 check passed
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.

1 participant