Alternatively, use tRPC and never think about query keys again
Problem:
With react-query, we may declare inconsistent query keys. That leads to cache misses and duplicated cache entries. 👎
Solution:
1. Wrap each useQuery call in a custom hook. Store the hooks in /hooks.
2. Put the fetch call in the custom hook. *Don’t export it*.
3. Forbid calling useQuery outside /hooks via ESLint’s no-restricted-imports. Forbid calling fetch outside /hooks too.
This assures the hook is the only way to query. 👍