Skip to content

Conversation

@Heo-Donghyuk
Copy link
Collaborator

📝 개요

queryKey 관리를 위한 queryOption 객체 정의

🎯 목적

queryKey가 관리되지 않아, API 스펙 변경 시 useQuery에는 변경, invalidateQuery에서는 변경하지 않는 실수가 있었습니다.
이를 방지하기 위한 queryOption 객체를 정의해 보았습니다.

참고사항

어떤 방식을 도입할지 고민한 내용을 아래에 정리했으니 참고하시면 좋을 것 같습니다!
https://plume-forest-69a.notion.site/QueryKey-23505cf56f5680169a1ae9bae8a2c68b?source=copy_link

💬 논의 사항 (선택)

지금 방식은 사용 시 아래와 같은 형태로 사용해야 하는데 너무 복잡한가요?
1, 2번 방법 중 어떤 방법이 나은지 알려주세요~

// 1번 방법
useQuery(
  {
    queryKey: queryOption.team.comment(teamId).queryFn,
    ...
  }
)
// 2번 방법: 코드는 짧아지지만 teamsQuery, noticesQuery ... 등으로 나뉘어서 숙지가 조금 필요함
useQuery(
  {
    queryKey: teamsQuery.comment(teamId).queryFn,
    ...
  }
)

@redzzzi
Copy link
Collaborator

redzzzi commented Jul 20, 2025

수고하셨습니다. 네이밍 규칙도 잘 정리되어 있어서 2번이 간결하고 좋은 것 같습니다! 👏👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants