Skip to content
Discussion options

You must be logged in to vote

It depends a lot on how you handle the stream and how you want to set the data, you could for example set the cache data after each chunk and even abstract this as a composable on top of useQuery. Here is an example unit test from the codebase:

  it('works with a streamed response', async () => {
    async function* streamData() {
      yield 'hey'
      await delay(50)
      yield ' '
      await delay(50)
      yield 'you'
    }

    const { wrapper, queryCache } = mountSimple({
      key: ['key'],
      async query() {
        let result = ''
        for await (const chunk of streamData()) {
          result += chunk
          queryCache.setQueryData(['key'], result)
        }
        r…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants