Skip to content

useQuery의 queryKey를 어떤 방식으로 관리하시나요? #7

Answered by jhlee0409
Kimbangg asked this question in Code Smell
Discussion options

You must be logged in to vote

저의 경우
/~https://github.com/lukemorales/query-key-factory 라이브러리를 사용해서 관리하고 있는데요.
queryKeys를 관리하는 특정 도메인을 모체로 하는 객체를 만들고 하위의 all, list, detail 등 세부적인 API에 따라 나눈 후 사용하고 있습니다.

특정 도메인을 나타내기 위한 상수값만 관리를 하면 되기도 하구요
inferQueryKeyStore 메소드를 통해 특정 쿼리의 타입을 추출하여 타입 체크도 가능합니다!!

Replies: 8 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Kimbangg
Comment options

Kimbangg Jan 14, 2025
Maintainer Author

@jhlee0409
Comment options

Answer selected by Kimbangg
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment