Skip to content

Conversation

@leojsantos
Copy link
Contributor

The updateQuery is something I use a lot while developing in React. I find it particularly useful because, in many cases, it eliminates the need to use readQuery and writeQuery. I just created a function that calls the existing updateQuery function in the ObservableQuery and returned it in the useQuery, so the cache of a query can be modified like this:

selectedChannelQuery.updateQuery(previousResult => ({
  ...previousResult,
  channel: {
    ...previousResult.channel,
    messages: [
      ...previousResult.channel.messages,
      result?.data.message,
    ],
  },
}))

@leojsantos leojsantos changed the title Add updateQuery to useQuery feat: add updateQuery to useQuery May 2, 2024
@Akryum Akryum merged commit d1098be into vuejs:v4 Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants