lukemorales / query-key-factory

A library for creating typesafe standardized query keys, useful for cache management in @tanstack/query
https://www.npmjs.com/package/@lukemorales/query-key-factory
MIT License
1.16k stars 32 forks source link

Unable to define `placeholderData` on a query key. #85

Open dvsweeney9 opened 6 months ago

dvsweeney9 commented 6 months ago

The fix added here: https://github.com/lukemorales/query-key-factory/commit/9b5401cdd8ff6b3a85074285ab7ed68a6ab3a252 locked down the valid factory keys to 'queryKey' | 'queryFn' | 'contextQueries' however this removes the ability to utilize placeholderData as specified here: https://tanstack.com/query/latest/docs/framework/react/guides/placeholder-query-data

This is something my company uses in a few places. Is it possible to either revert the change or improve it to include all available factory keys?

lukemorales commented 6 months ago

@dvsweeney9 the change won't be reverted as this was always the expected behavior and the fix actually makes your system more type-safe now. If you were using it before, believe me, placeholderData was never passed down to your useQuery hooks, and now, typescript is telling you that.

All queryOptions will be accepted on a new major release I'm working as we speak