Skip to content
Source
Sign inSign up
TanStack/query

fix(vue-query): allow computed ref as enabled property in queryOptions #10465

Mergedbyungsker(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/10465/headmerged by DamianOsipiuk(GitHub profile, opens in a new tab) View on GitHub

Showing 3 changed files with 69 additions and 3 deletions.

x
0 of 3 viewed, 3 left
14 additions and 0 deletions.changeset/fix-vue-query-options-enabled.mdAdded
View file
@@ -0,0 +1,14 @@
+---
+'@tanstack/vue-query': patch
+---
+​
+fix(vue-query): allow computed ref and other reactive values as `enabled` property in queryOptions
+​
+This fixes a regression introduced in #10452 where `queryOptions` only accepted getter functions for the `enabled` property, but not `computed` refs or other reactive values.
+​
+Now the `enabled` property in `queryOptions` correctly accepts:
+- `boolean` values
+- `Ref<boolean>`
+- `ComputedRef<boolean>`
+- `() => boolean` getter functions
+- `(query) => boolean` query predicate functions
46 additions and 1 deletionpackages/vue-query/src/__tests__/queryOptions.test-d.tsModified
View file
@@ -1,5 +1,5 @@
import { assertType, describe, expectTypeOf, it } from 'vitest'
-import { reactive, ref } from 'vue-demi'
+import { computed, reactive, ref } from 'vue-demi'
import { dataTagSymbol } from '@tanstack/query-core'
import { queryKey } from '@tanstack/query-test-utils'
import { QueryClient } from '../queryClient'
@@ -253,4 +253,49 @@