Commit cd6b1b7
authored
fix(query): pass enabled option into queryOptions mutator (#3389)
* fix(query): pass enabled option into queryOptions mutator
When `allParamsOptional` is combined with a custom `queryOptions` mutator,
the generated query options helper passed `{ ...queryOptions, queryKey,
queryFn }` to the mutator, dropping the `enabled` guard (and any override
options) that the non-mutator branch emits via `queryOptionsImp`.
The query then ran even while a required path param was nullish, hitting a
broken URL. Pass the same object shape the non-mutator branch returns so the
`enabled` guard reaches the mutator, and so `...queryOptions` stays last and
remains overridable.
Closes #1522
* test(query): match issue-1522 mutator call verbatim
The issue-1522 regression test sliced the generated `customQueryOptions(...)`
call by searching for the first `});`, which a nested call site in the
argument could truncate. Match the whole call verbatim instead — generation
is deterministic — and assert it appears once per query helper.1 parent c2959b3 commit cd6b1b7
9 files changed
Lines changed: 585 additions & 6 deletions
File tree
- packages/query/src
- tests
- __snapshots__/react-query
- issue-1522
- model
- use-invalidate-with-query-options-mutator
- configs
- specifications
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
653 | 656 | | |
654 | | - | |
| 657 | + | |
655 | 658 | | |
656 | 659 | | |
657 | 660 | | |
| |||
0 commit comments