Skip to content

Provide initialData in queryFn via QueryFunctionContext #9389

Answered by TkDodo
mydesweb asked this question in Ideas
Discussion options

You must be logged in to vote

we inject the client and the queryKey, so you can do:

queryFn: async ({ client, queryKey }) => {
  const response = await makeRequest(queryKey)
  if (is304(response)) {
    return client.getQueryData(queryKey)
  }

  return response.data
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mydesweb
Comment options

Answer selected by mydesweb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants