sanity icon indicating copy to clipboard operation
sanity copied to clipboard

useSanityQuery does not update data on reactive parameter change and refresh()

Open jeffreyroulston opened this issue 6 months ago • 0 comments

When using the useSanityQuery the query fails to update the data state when a reactive parameter passed to it changes. This issue occurs both when the refresh function is called directly and when a reactive dependency is modified.

Using the more explicit useAsyncData composable with a manual watch on the reactive parameter correctly triggers a refetch and updates the data.

Version

module: 1.13.3 nuxt: 3.17.5

Reproduction

This issue exists which refresh is called directly and when a reactive parameter changes

` // this makes a network request to sanity but does not update the data state const { data } = useSanityQuery<articleQueryResult>(articleByDateQuery, { date: dateRef })

// this works and correctly updates data const { data } = useAsyncData('articles', () => sanity.fetch<articleQueryResult>(articleByDateQuery, { date: dateRef.value }), {watch: [dateRef]}) `

jeffreyroulston avatar Jun 29 '25 12:06 jeffreyroulston