Skip to content

Prevent query from running after query key changed #5808

Closed Answered by TkDodo
antonisprovidakis asked this question in Q&A
Discussion options

You must be logged in to vote

interesting. what you can do is:

  • run the query with the slug only
  • in the queryFn, make a lookup via queryClient.getQueryData on the job query
  • use the id for the request if you find it, otherwise, use the slug

that way, you would only have one query, which always has the slug in the QueryKey, and you potentially "translate" it to an id right before the request.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@antonisprovidakis
Comment options

@TkDodo
Comment options

Answer selected by antonisprovidakis
@antonisprovidakis
Comment options

@antonisprovidakis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants