github logaretm/villus v2.1.0
v2.1

latest releases: v3.5.0, v3.4.0, v3.3.0...
21 months ago

A couple of nice features to help with the caching and fetching logic of mutations and queries. As always, feedback is welcome and make sure to report any bugs you encounter.

🆕 New Features

Added the ability to tag queries using the tags option when calling useQuery. This marks a query with the specified tags for a couple of features.

Clearing tagged queries cache after mutation

const { data } = useQuery(GetPosts, {
  tags: ['all_posts'],
});

// This will clear the previous query cache whenever `execute` concludes successfully.
const { execute } = useMutation(CreatePost, {
  clearCacheTags: ['all_posts'],
});

Refetching tagged queries cache after mutation

const { data } = useQuery(GetPosts, {
  tags: ['all_posts'],
});

// This will auto-fetch the previous query whenever `execute` concludes successfully.
const { execute } = useMutation(CreatePost, {
  refetchTags: ['all_posts'],
});

This refetching bypasses the cache so it will also clear the affected queries cache as well, so there is some overlap between clearing and autofetching.

Don't miss a new villus release

NewReleases is sending notifications on new releases.