Skip to content

Conversation

@ujinsim
Copy link
Collaborator

@ujinsim ujinsim commented Sep 13, 2025

🚀 기능 추가

배경

  • 각 쿼리에서 queryKey와 queryFn을 따로 선언하다 보니 응집도가 떨어짐
  • 쿼리 키 네이밍이 일관되지 않아 무효화 범위 파악이 어렵고 중복 선언이 많음
    정리 자료

🏗 작업 내용

  • checklist 쿼리 키를 Query Key Factory 기반으로 리팩토링했습니다
  • useChecklistInfo, useSendRequiredItems 훅을 queries.checklist.* API로 일관되게 변경했습니다
  • queries/index.ts에서 mergeQueryKeys로 통합 관리
  • react query devtools 설치
  • 추가적으로 다른 api는 작업해주시면서 같이 적용해주시면 될거같습니다 현재는 checklist만 적용돼있습니다

👀 관련 이슈 번호

Summary by CodeRabbit

  • 신규 기능
    • 개발 모드에서 React Query Devtools 제공(프로덕션에는 노출되지 않음).
  • 리팩터
    • 쿼리 키를 중앙에서 관리하도록 구조 개선.
    • 체크리스트 관련 훅과 쿼리 무효화 로직을 통일해 일관성 및 유지보수성 향상.
  • 잡무(Chores)
    • 개발 및 데이터 페칭 체계 강화를 위한 의존성 추가.

@ujinsim ujinsim self-assigned this Sep 13, 2025
@ujinsim ujinsim requested a review from ydw1996 as a code owner September 13, 2025 08:47
@vercel
Copy link

vercel bot commented Sep 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
zipzip Ready Ready Preview Comment Sep 13, 2025 8:47am

@coderabbitai
Copy link

coderabbitai bot commented Sep 13, 2025

Walkthrough

React Query 쿼리 키를 중앙화하고 체크리스트 관련 훅을 해당 키로 마이그레이션했다. 패키지에 쿼리 키 팩토리와 React Query Devtools를 추가하고, 개발 환경에서만 Devtools를 렌더링하도록 레이아웃을 수정했다.

Changes

Cohort / File(s) Summary
Dependencies
package.json
@lukemorales/query-key-factory@tanstack/react-query-devtoolsdependencies에 추가
Devtools 통합
src/app/layout.tsx
개발 모드에서만 <ReactQueryDevtools initialIsOpen={false} /> 렌더링 추가
쿼리키 레지스트리 도입
src/queries/index.ts, src/queries/checkList/index.ts
createQueryKeyschecklist 키 정의, mergeQueryKeysqueries 중앙 레지스트리 생성 및 export
훅 마이그레이션 (체크리스트)
src/queries/checkList/useChecklistInfo.ts, src/queries/checkList/useSendRequiredItems.ts
훅에서 하드코딩된 키/함수를 제거하고 queries.checklist.info 사용; 뮤테이션 성공 시 qc.invalidateQueries가 중앙 키(queries.checklist.info.queryKey)로 무효화

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App (RootLayout)
  participant RQ as React Query
  participant Devtools as ReactQueryDevtools
  Note over App: NODE_ENV === 'development'
  App->>Devtools: 렌더링 (initialIsOpen=false)
  App->>RQ: Provider 하위에서 앱 렌더링
  Note over Devtools,RQ: Devtools는 개발 환경에서만 표시
Loading
sequenceDiagram
  autonumber
  participant Hook as useChecklistInfo
  participant Keys as queries.checklist.info
  participant RQ as React Query
  participant API as getChecklistInfo()
  Hook->>RQ: useQuery(Keys)
  RQ->>API: queryFn 호출
  API-->>RQ: ChecklistResponse
  RQ-->>Hook: 데이터 반환

  participant Mut as useSendRequiredItems
  participant QC as QueryClient
  Mut->>API: mutationFn 실행
  API-->>Mut: 성공
  Mut->>QC: invalidateQueries(queryKey = Keys.queryKey)
  QC-->>RQ: 해당 쿼리 무효화/재패치 트리거
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

✨ Feature

Suggested reviewers

  • ydw1996
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#101

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning 체크리스트 관련 리팩토링은 이슈 범위에 해당하지만 package.json에 @tanstack/react-query-devtools 추가 및 src/app/layout.tsx에서 ReactQueryDevtools 렌더링을 추가한 변경은 '쿼리키 분리' 이슈([#101])의 핵심 요구사항과 직접 관련이 없으므로 범위를 벗어난 변경으로 판단됩니다. devtools 추가는 개발 편의성 향상 목적일 수 있으나 기능 분리 원칙상 별도 PR로 관리하는 편이 명확합니다. 그 외 checklist 쪽 변경은 스코프 내로 보입니다. 해결 방안으로 devtools 의존성 및 layout 변경을 별도의 PR로 분리하거나 이 PR 설명에 해당 변경의 목적·영향을 명확히 기술하고 팀의 승인(또는 이슈 업데이트)을 받으시기 바랍니다.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed PR 제목 '[FEAT] query-key-factory 적용'은 이번 변경의 핵심인 query-key-factory 기반 쿼리 키 리팩토링을 직접적으로 표현합니다. 한 문장으로 간결하며 파일 목록·이모지·모호한 표현 없이 주된 변경 목적을 명확히 전달합니다. 따라서 동료가 변경 이력을 스캔할 때 주된 목적을 빠르게 파악할 수 있습니다.
Linked Issues Check ✅ Passed 이 PR은 링크된 이슈 [#101]의 '쿼리키 분리' 목표를 충족합니다: src/queries/checkList/index.ts에서 createQueryKeys로 checklist 키를 정의하고 src/queries/index.ts에서 mergeQueryKeys로 통합했으며 useChecklistInfo와 useSendRequiredItems 훅이 queries.checklist.* API로 변경되었습니다. raw_summary와 PR 설명에 따른 코드 변경은 이슈의 코딩 관련 요구사항과 일치합니다. 따라서 관련 이슈의 구현 항목은 충족된 것으로 보입니다.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ujinsim, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 React Query의 queryKey 관리 방식을 개선하여 코드의 응집도를 높이고 쿼리 무효화 범위를 명확하게 하기 위한 변경사항을 포함합니다. query-key-factory 라이브러리를 도입하여 쿼리 키를 체계적으로 정의하고 관리하며, checklist 관련 쿼리에 우선적으로 적용되었습니다. 또한, 개발 편의성을 위해 React Query Devtools를 설치했습니다.

Highlights

  • Query Key Factory 적용: React Query의 queryKeyqueryFn의 응집도를 높이고 일관된 네이밍을 위해 @lukemorales/query-key-factory 라이브러리를 도입했습니다.
  • 체크리스트 쿼리 리팩토링: checklist 관련 쿼리 키를 Query Key Factory 기반으로 재구성하고, useChecklistInfouseSendRequiredItems 훅을 새로운 queries.checklist.* API를 사용하도록 변경했습니다.
  • 쿼리 키 통합 관리: src/queries/index.ts 파일을 신규 생성하여 mergeQueryKeys를 통해 모든 쿼리 키를 통합 관리할 수 있는 구조를 마련했습니다.
  • React Query Devtools 설치: 개발 환경에서 React Query의 상태를 시각적으로 확인할 수 있도록 @tanstack/react-query-devtools를 설치하고 src/app/layout.tsx에 추가했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

Update: 2025년 09월 13일 17시 48분 56초
Storybook 미리보기 🎉: https://6894a6ac4e37e8794db64f74-fvnyrdssyv.chromatic.com/

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

@lukemorales/query-key-factory를 도입하여 React Query의 키 관리를 개선하고, checklist 관련 쿼리를 리팩토링한 점이 좋습니다. 이를 통해 쿼리 키의 응집도를 높이고 일관성을 확보하여 유지보수성을 향상시켰습니다. 또한, 개발 환경에 ReactQueryDevtools를 추가하여 디버깅 편의성을 높인 점도 훌륭합니다.

한 가지 개선점을 제안합니다. useSendRequiredItems 훅에서 쿼리를 무효화할 때, info 쿼리 키만 특정하기보다는 checklist 도메인 전체를 무효화하는 것이 더 견고한 설계입니다. 이렇게 하면 향후 관련 쿼리가 추가되더라도 데이터 정합성을 유지하기 용이합니다. 자세한 내용은 관련 코드에 남긴 코멘트를 참고해주세요.

Comment on lines +15 to 17
qc.invalidateQueries({
queryKey: queries.checklist.info.queryKey,
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

queryKeyqueries.checklist.info.queryKey로 지정하여 무효화 범위를 너무 구체적으로 한정하고 있습니다. 기존 코드에서는 ['checklist']를 사용하여 checklist와 관련된 모든 쿼리를 무효화했습니다.

향후 checklist와 관련된 다른 쿼리(예: 상세 정보)가 추가될 경우, 현재 코드는 해당 쿼리들을 무효화하지 못해 데이터 불일치를 유발할 수 있습니다.

queries.checklist.all을 사용하여 checklist 도메인 전체를 무효화하는 것이 더 견고하고 유지보수하기 좋은 방법입니다. 이렇게 하면 기존 코드의 동작과도 일치하게 됩니다.

Suggested change
qc.invalidateQueries({
queryKey: queries.checklist.info.queryKey,
});
qc.invalidateQueries({
queryKey: queries.checklist.all,
});

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/app/layout.tsx (1)

5-5: React Query Devtools는 dynamic import + SSR 비활성화로 개발 환경에서만 로드하세요

정적 import는 프로덕션 번들에 devtools 코드가 포함될 수 있고(트리셰이킹 실패 시), 서버 렌더링 경로에서 불필요한 모듈 해석이 발생할 수 있습니다. next/dynamic과 ssr: false를 사용해 개발에서만 지연 로드하는 쪽이 안전합니다.

아래처럼 변경을 제안합니다:

- import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
+ import dynamic from 'next/dynamic';
+ const ReactQueryDevtools =
+   process.env.NODE_ENV === 'development'
+     ? dynamic(
+         () =>
+           import('@tanstack/react-query-devtools').then(
+             (m) => m.ReactQueryDevtools
+           ),
+         { ssr: false }
+       )
+     : (() => null as any);
- {process.env.NODE_ENV === 'development' && <ReactQueryDevtools initialIsOpen={false} />}
+ <ReactQueryDevtools initialIsOpen={false} />

Also applies to: 72-72

package.json (1)

15-15: Devtools는 devDependencies로 이동 권장 + TanStack 패키지 버전 정렬 제안

  • devtools는 개발 전용이므로 devDependencies로 옮기면 프로덕션 설치 용량을 줄일 수 있습니다.
  • react-query(현재 ^5.84.0)와 devtools(^5.87.4)의 마이너 버전을 맞추면 타입/옵션 차이로 인한 미묘한 불일치를 줄일 수 있습니다. 둘 다 동일 마이너로 정렬을 고려해 주세요.

예시:

  "dependencies": {
     "@lukemorales/query-key-factory": "^1.3.4",
-    "@tanstack/react-query": "^5.84.0",
-    "@tanstack/react-query-devtools": "^5.87.4",
+    "@tanstack/react-query": "^5.87.4",
     ...
  },
  "devDependencies": {
+   "@tanstack/react-query-devtools": "^5.87.4",
    ...
  }

Also applies to: 17-17

src/queries/checkList/index.ts (1)

1-3: 케이스 일관성: 'checkList' vs 'checklist'

폴더/파일 경로가 checkList(카멜)와 checklist(스네이크/로워)로 혼재합니다. CI/배포 환경이 대소문자 구분 파일시스템이면 혼동 여지가 있으니 네이밍 컨벤션을 통일하는 것을 권장합니다.

src/queries/index.ts (1)

1-6: 중앙 레지스트리 구성 OK

  • mergeQueryKeys로 확장 가능하게 열어둔 구조가 좋습니다. 이후 다른 도메인 키를 합칠 때도 변경 범위가 최소화됩니다.

필요하시면 users/todos 등 스캐폴딩 예시(PR 추가 커밋용)도 드릴게요.

src/queries/checkList/useChecklistInfo.ts (1)

2-2: useQuery에 key 객체 직접 전달: 간결하고 타입 안정적입니다

  • queryFn/반환 타입이 키 팩토리에서 추론되어 훅 코드가 단순해졌습니다.

체크리스트 데이터 변동 빈도가 낮다면, 필요 시 훅 레벨에서 staleTime/gcTime을 부여해 불필요한 재요청을 줄이는 것도 고려해 보세요.

Also applies to: 5-5

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f5e5cb and b680e58.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • src/app/layout.tsx (2 hunks)
  • src/queries/checkList/index.ts (1 hunks)
  • src/queries/checkList/useChecklistInfo.ts (1 hunks)
  • src/queries/checkList/useSendRequiredItems.ts (1 hunks)
  • src/queries/index.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/queries/index.ts (1)
src/queries/checkList/index.ts (1)
  • checklist (5-11)
src/queries/checkList/useSendRequiredItems.ts (3)
src/services/checkList.ts (1)
  • sendRequiredItems (8-11)
src/utils/toastStyles.ts (1)
  • TOAST_STYLES (1-24)
src/queries/index.ts (1)
  • queries (4-4)
src/queries/checkList/index.ts (2)
src/types/checklist.ts (1)
  • ChecklistResponse (24-28)
src/services/checkList.ts (1)
  • getChecklistInfo (13-16)
src/queries/checkList/useChecklistInfo.ts (1)
src/queries/index.ts (1)
  • queries (4-4)
🔇 Additional comments (1)
src/queries/checkList/index.ts (1)

1-11: Query Key Factory 적용 깔끔합니다

  • queryKey와 queryFn을 한 곳에서 관리하게 되어 훅 구현이 간결해집니다.
  • all 네임스페이스를 둔 것도 이후 일괄 무효화 전략에 유용합니다.

import { sendRequiredItems } from '@/services/checkList';
import toast from 'react-hot-toast';
import { TOAST_STYLES } from '@/utils/toastStyles';
import { queries } from '@/queries';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

중앙화된 queryKey로 invalidation 전환: 좋습니다

  • queries.checklist.info.queryKey 사용으로 키 오탈자/불일치 위험이 사라집니다.

레거시 하드코딩 키가 남아 있는지 확인하려면 아래 스크립트를 제안합니다.

Also applies to: 8-8, 15-16


🏁 Script executed:

#!/bin/bash
# 'checklist' 관련 쿼리 무효화/사용 패턴 점검
rg -nP -C2 "(invalidateQueries|prefetchQuery|ensureQueryData)\s*\(\s*\{?\s*queryKey:\s*\[?['\"]checklist['\"]" --type=ts --type=tsx

Length of output: 27


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# 'checklist' 관련 쿼리 무효화/사용 패턴 재검증 (TS/TSX/JS/JSX)
echo "1) invalidate/prefetch/ensure with queryKey: ['checklist']"
rg -nP -C2 "(invalidateQueries|prefetchQuery|ensureQueryData)\s*\(\s*\{?\s*queryKey\s*:\s*\[?\s*['\"]checklist['\"]" -g '!**/node_modules/**' -g '**/*.ts' -g '**/*.tsx' -g '**/*.js' -g '**/*.jsx' || echo "no matches"

echo "2) invalidate/prefetch/ensure called with 'checklist' directly"
rg -nP -C2 "(invalidateQueries|prefetchQuery|ensureQueryData)\s*\(\s*['\"]checklist['\"]" -g '!**/node_modules/**' -g '**/*.ts' -g '**/*.tsx' -g '**/*.js' -g '**/*.jsx' || echo "no matches"

echo "3) queryKey: ['checklist'] anywhere"
rg -nP -C2 "queryKey\s*:\s*\[?\s*['\"]checklist['\"]" -g '!**/node_modules/**' -g '**/*.ts' -g '**/*.tsx' -g '**/*.js' -g '**/*.jsx' || echo "no matches"

Length of output: 537


하드코딩된 'checklist' queryKey 교체 필요

src/queries/houseMemo/useChecklistInfo.ts (줄 7): queryKey: ['checklist']queries.checklist.info.queryKey 로 교체하세요.

🤖 Prompt for AI Agents
In src/queries/checkList/useSendRequiredItems.ts around line 5, replace the
hardcoded queryKey ['checklist'] with the centralized constant
queries.checklist.info.queryKey; update any import or usage so the hook uses
queries.checklist.info.queryKey instead of the literal array, ensuring you
import queries from '@/queries' if not already and remove the hardcoded array.

Copy link
Member

@ydw1996 ydw1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 노션까지 정리해주셔서 감사합니다 🙏
Query Key Factory 기반으로 구조가 일관되게 정리되어 좋았고,
mergeQueryKeys 중앙 관리로 앞으로 다른 API 확장 시에도 통일성 있게 가져갈 수 있을 것 같습니다!

@ujinsim ujinsim merged commit 16d9c08 into main Sep 15, 2025
9 checks passed
@ujinsim ujinsim deleted the feat/#101 branch September 16, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 쿼리키 분리

3 participants