Skip to content

Support Map and Set as query keys #9199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

Zentrik
Copy link
Contributor

@Zentrik Zentrik commented May 27, 2025

I'm not sure if this is intended to be supported but I figured it wouldn't hurt to open this pr. Feel free to close if we don't want to support Map and Set instances as query keys. But I found this useful for me.

JSON.stringify doesn't properly support instances of these types and will just return "{}". xref #6444

JSON.stringify doesn't properly support instances of these types and will just return "{}".
xref TanStack#6444
@TkDodo
Copy link
Collaborator

TkDodo commented May 27, 2025

we want to keep being json compatible because it’s hard to justify drawing a line otherwise. If we add maps and sets, why not symbols? Why not Date? Why not undefined ? Why not Regexp? Why not ...

You can always add a global queryKeyHashFn and use something like superjson to do custom serialization.

@TkDodo TkDodo closed this May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants