Skip to content

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

@jeffreyroulston

Description

@jeffreyroulston

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(articleByDateQuery, { date: dateRef })

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions