Feat: config based invalidation #2679
Open
+302
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces configuration-based query invalidation support, initially implemented for
angular-query. This allows developers to define cache invalidation rules directly in [orval.config.ts] rather than manually callingqueryClient.invalidateQueries()in every component.This is based of #2676 but without the optimistic update for now.
Usage
In your [orval.config.ts], you can now specify
mutationInvalidateswithin thequeryoptions:Implementation Guide for Other Generators
The core types and normalization logic have been added to
@orval/core, making this feature available for all generators to implement.To support this in other clients (e.g.,
react-query,vue-query,svelte-query), generators need to:Read the Config: Access
mutationInvalidatesfrom thequeryoptions object (available in [NormalizedQueryOptions]).Check for Invalidations: If an entry exists for the current mutation operation, it will be a string array of query operation names.
Generate Invalidation Code:
onSuccesscallback (or equivalent lifecycle hook), generate code to invalidate the target queries.getListPetsQueryKey()) to ensure type safety and correctness.Abstract Example:
Checklist
angular-query