keys.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export const queryKeys = {
  2. users: {
  3. all: ['users'] as const,
  4. user: (userId: number) => ['user', userId] as const,
  5. lists: () => [...queryKeys.users.all, 'list'] as const,
  6. list: (params: unknown) => [...queryKeys.users.lists(), params] as const,
  7. details: () => [...queryKeys.users.all, 'detail'] as const,
  8. detail: (id: number | string) =>
  9. [...queryKeys.users.details(), id] as const,
  10. },
  11. posts: {
  12. all: ['posts'] as const,
  13. lists: () => [...queryKeys.posts.all, 'list'] as const,
  14. list: (params: unknown) => [...queryKeys.posts.lists(), params] as const,
  15. details: () => [...queryKeys.posts.all, 'detail'] as const,
  16. detail: (id: number | string) =>
  17. [...queryKeys.posts.details(), id] as const,
  18. },
  19. location: {
  20. all: ['location'] as const,
  21. provinces: ['location', 'provinces'] as const,
  22. cities: (provinceId: number | string) =>
  23. ['location', 'cities', provinceId] as const,
  24. },
  25. evaluations: {
  26. all: ['evaluations'] as const,
  27. lists: () => [...queryKeys.evaluations.all, 'list'] as const,
  28. list: (params: unknown) =>
  29. [...queryKeys.evaluations.lists(), params] as const,
  30. details: () => [...queryKeys.evaluations.all, 'detail'] as const,
  31. detail: (id: number | string) =>
  32. [...queryKeys.evaluations.details(), id] as const,
  33. items: () => [...queryKeys.evaluations.all, 'item'] as const,
  34. item: () => [...queryKeys.evaluations.items()] as const,
  35. },
  36. }