Skip to content

Conversation

@zaguiini
Copy link
Contributor

@zaguiini zaguiini commented Oct 21, 2021

Closes #2772.

Usage example (parts of the code omitted for brevity):

persistQueryClient({
  queryClient,
  persistor: localStoragePersistor,
  dehydrateOptions: {
    shouldDehydrateQuery: (query: Query) => {
      const shouldPersist = query.meta.persist ?? true;

      return shouldPersist;
    },
  },
});

const FetchData = () => {
  const queryKey = ["repoData", 123];

  useQuery(queryKey, {
    meta: {
      persist: false,
    },
  });

  return null;
};

@vercel
Copy link

vercel bot commented Oct 21, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tanstack/react-query/6DGpHYWBTprMYnqWwdxRd7dg7UEY
✅ Preview: https://react-query-git-fork-zaguiini-feature-meta-fiel-ff32b5-tanstack.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 21, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@zaguiini zaguiini changed the title feat(query): add meta field feat(useQuery): add meta field Oct 21, 2021
Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

so that you can access it from within the queryFn, and generally everywhere where the context is available. This should also be documented then please

@zaguiini
Copy link
Contributor Author

Thanks for the feedback, @TkDodo! Please take a second look.

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

looking good, please have a look at one more finding

@zaguiini
Copy link
Contributor Author

Thanks for the thorough review, @TkDodo. On to the next -- and hopefully, last -- round of feedback!

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

looks awesome 🚀

@TkDodo TkDodo merged commit 4472bae into TanStack:master Oct 26, 2021
@tannerlinsley
Copy link
Member

🎉 This PR is included in version 3.29.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zaguiini zaguiini deleted the feature/meta-field-on-query branch October 26, 2021 20:52
sejas added a commit to Automattic/wp-calypso that referenced this pull request Oct 19, 2022
In these PR's we've introduced the persistance of react query using IndexDB.
- #56828
- #68187

To avoid this persiting a query we need to add a meta property `persist: false` that was introduced on React Query by @zaguiini in TanStack/query#2818
danielbachhuber pushed a commit to Automattic/wp-calypso that referenced this pull request Oct 19, 2022
In these PR's we've introduced the persistance of react query using IndexDB.
- #56828
- #68187

To avoid this persiting a query we need to add a meta property `persist: false` that was introduced on React Query by @zaguiini in TanStack/query#2818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants