Invalidating queryKey with variable doesn't work
Hi guys,
I'm encountering issues when trying to invalidate queries with a variable in the query key during the onSettled of a useMutation.
Basically trying something like this (with version
5.84.1):
Something has a prop id, when logging the variables in onSettled I do get a result.
When I hardcode the id into the key directly, it works fine, but not when using the variable. Is this a bug or is that simply not possible?
Is there some other way I can achieve the same effect?6 Replies
like-gold•4mo ago
Hard to say without more code, but make sure you are not using different types, make sure you pass
id always as number or as stringeastern-cyanOP•4mo ago
Thanks for replying, we use UUIDs so the id is always a string.
Here's a bit more code if that helps:
like-gold•4mo ago
it should've worked fine, maybe the UUID you pass as a variable is different somehow?
like, it's made into lowercase or uppercase or it gets it's lines stripped
eastern-cyanOP•4mo ago
When logging the variables.id it's the correct one 🥲 It's very weird
Hmmmm actually it does seem that there is a mismatch. Will look further into this. Thanks for thinking with me!
Yep, got it fixed :blbsmilesweat2: yey for long UUIDs, hard to spot differences sometimes haha
like-gold•4mo ago
long UUIDs? you mean, uuid with -?
I know it's common to work with UUIDs in these formats:
Hence why'd you want to normalize them if you have inconsistent ones
eastern-cyanOP•4mo ago
We only work with the first, but the ids were very similar so somehow I managed to still oversee that tiny difference