-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat(tanstack-query): new implementation of tanstack-query react hooks #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
|
Warning Rate limit exceeded@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 43 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughReplaces legacy tanstack-query with a new typed client at Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas to review closely:
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces major new sample applications and reorganizes the TanStack Query integration for ZenStack v3. The changes include two new sample projects (ORM and Next.js), a complete reimplementation of the TanStack Query client package, and various dependency consolidations.
- Adds two comprehensive sample applications demonstrating ZenStack v3 usage with ORM and Next.js + TanStack Query
- Relocates and completely rewrites the TanStack Query integration from
packages/tanstack-querytopackages/clients/tanstack-querywith full implementation - Consolidates dependency versions across the monorepo using catalog references
- Updates documentation and comments for clarity
Reviewed Changes
Copilot reviewed 40 out of 57 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| samples/orm/* | New ORM sample with schema, generated files, and main application demonstrating ZenStack ORM features |
| samples/next.js/* | New Next.js sample app with TanStack Query integration, including frontend components and API routes |
| packages/clients/tanstack-query/* | Complete TanStack Query client implementation with hooks, optimistic updates, and cache management |
| packages/tanstack-query/* | Removed old stub implementation |
| pnpm-workspace.yaml | Added catalog entries for React and TanStack Query dependencies |
| packages/sdk/src/model-utils.ts | Comment clarifications |
| README.md | Updated quick start section with new sample references |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/clients/tanstack-query/src/utils/nested-write-visitor.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Nitpick comments (2)
samples/next.js/zenstack/seed.ts (1)
15-20: Potential ID conflict with schema defaults.The seed data uses hardcoded IDs ('1', '2'), but the schema defines
idwith@default(cuid()). While explicitly provided IDs should override the default, this mixing of manual and auto-generated ID strategies could cause confusion. Consider either:
- Using auto-generated IDs by omitting the
idfield- Documenting why hardcoded IDs are used here
await db.user.createMany({ data: [ - { id: '1', name: 'Alice', email: '[email protected]' }, - { id: '2', name: 'Bob', email: '[email protected]' }, + { name: 'Alice', email: '[email protected]' }, + { name: 'Bob', email: '[email protected]' }, ], });samples/next.js/app/providers.tsx (1)
7-7: Verify QueryClient instantiation pattern for Next.js App Router.The
QueryClientis instantiated at module scope. While this works for client-side only code, the recommended pattern for Next.js App Router is to create the client inside the component or use a factory function to avoid potential issues if this module is ever evaluated in different contexts.Consider this pattern from TanStack Query documentation:
'use client'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { useState } from 'react'; export default function Providers({ children }: { children: ReactNode }) { const [queryClient] = useState(() => new QueryClient()); return ( <QueryClientProvider client={queryClient}> <QuerySettingsProvider value={{ endpoint: '/api/model' }}>{children}</QuerySettingsProvider> </QueryClientProvider> ); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlsamples/next.js/app/favicon.icois excluded by!**/*.icosamples/next.js/public/file.svgis excluded by!**/*.svgsamples/next.js/public/globe.svgis excluded by!**/*.svgsamples/next.js/public/next.svgis excluded by!**/*.svgsamples/next.js/public/vercel.svgis excluded by!**/*.svgsamples/next.js/public/window.svgis excluded by!**/*.svg
📒 Files selected for processing (40)
README.md(1 hunks)package.json(1 hunks)packages/cli/package.json(1 hunks)packages/clients/tanstack-query/package.json(1 hunks)packages/clients/tanstack-query/src/react.ts(1 hunks)packages/clients/tanstack-query/src/utils/common.ts(1 hunks)packages/clients/tanstack-query/src/utils/mutator.ts(1 hunks)packages/clients/tanstack-query/src/utils/nested-read-visitor.ts(1 hunks)packages/clients/tanstack-query/src/utils/nested-write-visitor.ts(1 hunks)packages/clients/tanstack-query/src/utils/query-analysis.ts(1 hunks)packages/clients/tanstack-query/src/utils/serialization.ts(1 hunks)packages/clients/tanstack-query/src/utils/types.ts(1 hunks)packages/clients/tanstack-query/tsconfig.json(1 hunks)packages/orm/package.json(1 hunks)packages/plugins/policy/package.json(1 hunks)packages/sdk/src/model-utils.ts(2 hunks)packages/tanstack-query/package.json(0 hunks)packages/tanstack-query/src/react.ts(0 hunks)packages/tanstack-query/tsconfig.json(0 hunks)packages/testtools/package.json(1 hunks)pnpm-workspace.yaml(1 hunks)samples/next.js/.gitignore(1 hunks)samples/next.js/README.md(1 hunks)samples/next.js/app/api/model/[...path]/route.ts(1 hunks)samples/next.js/app/globals.css(1 hunks)samples/next.js/app/layout.tsx(1 hunks)samples/next.js/app/page.tsx(1 hunks)samples/next.js/app/providers.tsx(1 hunks)samples/next.js/eslint.config.mjs(1 hunks)samples/next.js/lib/db.ts(1 hunks)samples/next.js/next.config.ts(1 hunks)samples/next.js/package.json(1 hunks)samples/next.js/postcss.config.mjs(1 hunks)samples/next.js/tsconfig.json(1 hunks)samples/next.js/zenstack/input.ts(1 hunks)samples/next.js/zenstack/models.ts(1 hunks)samples/next.js/zenstack/schema.ts(1 hunks)samples/next.js/zenstack/schema.zmodel(1 hunks)samples/next.js/zenstack/seed.ts(1 hunks)samples/orm/package.json(2 hunks)
💤 Files with no reviewable changes (3)
- packages/tanstack-query/package.json
- packages/tanstack-query/tsconfig.json
- packages/tanstack-query/src/react.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
packages/sdk/src/model-utils.tssamples/next.js/zenstack/models.tssamples/next.js/zenstack/schema.tssamples/next.js/zenstack/schema.zmodelpackages/clients/tanstack-query/src/utils/query-analysis.ts
🧬 Code graph analysis (15)
packages/clients/tanstack-query/src/utils/mutator.ts (7)
packages/clients/tanstack-query/src/utils/types.ts (1)
ORMWriteActionType(19-19)packages/schema/src/schema.ts (2)
SchemaDef(10-18)FieldDef(60-75)packages/clients/tanstack-query/src/utils/nested-write-visitor.ts (1)
NestedWriteVisitor(98-359)packages/common-helpers/src/enumerable.ts (1)
enumerate(9-17)packages/common-helpers/src/tiny-invariant.ts (1)
invariant(4-14)packages/common-helpers/src/clone.ts (1)
clone(6-24)packages/common-helpers/src/zip.ts (1)
zip(4-11)
samples/next.js/zenstack/models.ts (1)
samples/orm/zenstack/models.ts (2)
User(13-13)Post(21-21)
samples/next.js/zenstack/schema.ts (2)
packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)packages/schema/src/schema.ts (1)
SchemaDef(10-18)
samples/next.js/app/layout.tsx (1)
samples/next.js/app/providers.tsx (1)
Providers(9-15)
packages/clients/tanstack-query/src/utils/nested-read-visitor.ts (1)
packages/schema/src/schema.ts (2)
FieldDef(60-75)SchemaDef(10-18)
packages/clients/tanstack-query/src/utils/nested-write-visitor.ts (3)
packages/schema/src/schema.ts (2)
FieldDef(60-75)SchemaDef(10-18)packages/clients/tanstack-query/src/utils/types.ts (3)
MaybePromise(1-1)ORMWriteActionType(19-19)ORMWriteActions(3-17)packages/common-helpers/src/enumerable.ts (1)
enumerate(9-17)
samples/next.js/app/api/model/[...path]/route.ts (2)
packages/server/src/adapter/next/index.ts (1)
NextRequestHandler(48-56)samples/next.js/lib/db.ts (1)
db(6-10)
samples/next.js/zenstack/seed.ts (2)
samples/next.js/lib/db.ts (1)
db(6-10)samples/next.js/zenstack/schema.ts (1)
schema(9-114)
samples/next.js/app/providers.tsx (1)
packages/clients/tanstack-query/src/react.ts (1)
QuerySettingsProvider(73-73)
samples/next.js/app/page.tsx (2)
packages/clients/tanstack-query/src/react.ts (1)
useModelQueries(209-311)samples/next.js/zenstack/schema.ts (1)
schema(9-114)
samples/next.js/lib/db.ts (1)
samples/next.js/zenstack/schema.ts (1)
schema(9-114)
samples/next.js/zenstack/input.ts (1)
samples/orm/zenstack/input.ts (3)
UserFindManyArgs(11-11)UserGetPayload(30-30)PostCreateArgs(54-54)
packages/clients/tanstack-query/src/react.ts (3)
packages/clients/tanstack-query/src/utils/common.ts (9)
APIContext(110-125)ExtraQueryOptions(100-105)ExtraMutationOptions(80-95)makeUrl(210-221)getQueryKey(179-189)fetcher(127-158)marshal(191-198)setupInvalidation(232-253)setupOptimisticUpdate(311-355)packages/schema/src/schema.ts (2)
SchemaDef(10-18)GetModels(109-109)packages/orm/src/client/crud-types.ts (18)
FindUniqueArgs(669-671)ModelResult(135-179)FindArgs(648-664)CreateArgs(677-682)BatchResult(201-201)CreateManyAndReturnArgs(686-692)UpdateArgs(815-821)UpdateManyArgs(823-826)UpdateManyAndReturnArgs(828-834)UpsertArgs(842-849)DeleteArgs(961-966)DeleteManyArgs(968-971)CountArgs(977-982)CountResult(988-998)AggregateArgs(1004-1018)AggregateResult(1044-1072)GroupByArgs(1091-1108)GroupByResult(1110-1144)
packages/clients/tanstack-query/src/utils/query-analysis.ts (5)
samples/next.js/zenstack/schema.ts (1)
schema(9-114)packages/schema/src/schema.ts (1)
SchemaDef(10-18)packages/clients/tanstack-query/src/utils/nested-read-visitor.ts (1)
NestedReadVisitor(15-61)packages/clients/tanstack-query/src/utils/types.ts (1)
ORMWriteActionType(19-19)packages/clients/tanstack-query/src/utils/nested-write-visitor.ts (1)
NestedWriteVisitor(98-359)
packages/clients/tanstack-query/src/utils/common.ts (5)
packages/clients/tanstack-query/src/utils/serialization.ts (2)
serialize(29-32)deserialize(37-39)packages/schema/src/schema.ts (1)
SchemaDef(10-18)packages/clients/tanstack-query/src/utils/types.ts (1)
ORMWriteActionType(19-19)packages/clients/tanstack-query/src/utils/query-analysis.ts (2)
getMutatedModels(30-78)getReadModels(14-25)packages/clients/tanstack-query/src/utils/mutator.ts (1)
applyMutation(19-39)
🪛 Biome (2.1.2)
packages/clients/tanstack-query/src/react.ts
[error] 83-83: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 220-220: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 224-224: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 228-228: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 232-232: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 236-236: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 240-240: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 244-244: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 248-248: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 252-252: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 256-256: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 260-260: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 264-264: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 268-268: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 272-272: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 276-276: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 280-280: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 284-284: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 288-288: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 292-292: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 296-296: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 300-300: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 304-304: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 308-308: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 320-320: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 328-328: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 343-343: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 351-351: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 369-369: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 373-373: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 399-399: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 403-403: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 443-443: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 444-444: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 465-465: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 497-497: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
🪛 GitHub Actions: Build and Test
samples/next.js/zenstack/models.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/next.config.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/app/globals.css
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/.gitignore
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/zenstack/schema.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/eslint.config.mjs
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/app/layout.tsx
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/zenstack/schema.zmodel
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/app/api/model/[...path]/route.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/zenstack/seed.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/README.md
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/app/providers.tsx
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/app/page.tsx
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/tsconfig.json
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/lib/db.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/package.json
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/postcss.config.mjs
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
samples/next.js/zenstack/input.ts
[error] 1-1: Next.js build failed with TypeScript error: Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'. GET handler signature is incompatible with expected Next.js type (NextRequest vs older Next.js NextRequest type). Command failed: 'pnpm run build'.
🔇 Additional comments (26)
samples/next.js/.gitignore (1)
1-41: The .gitignore content is correct and follows Next.js best practices.Standard patterns are in place for dependencies, build outputs, environment files, debug logs, and system files.
However, the reported pipeline failure is unrelated to this file. The build error indicates a TypeScript/route-handler issue in
/api/model/[...path](incompatible NextRequest types). Please provide the route handler file if you'd like review of that code segment, as the issue is in the actual implementation, not in the Git ignore configuration.packages/sdk/src/model-utils.ts (2)
29-30: Comment clarification improves explanation of field inheritance.The updated comment clearly explains why field-name matching is used instead of object-identity comparison—inherited fields may have different object identities across the model hierarchy. This aligns with the codebase's handling of field inheritance from base models and TypeDefs.
38-42: Comment clarification correctly documents id field precedence logic.The updated comment accurately describes the early-return behavior: if a model explicitly defines an id via
@idor@@id, subsequent checks should skip treating@uniqueor@@uniqueas fallback id fields. This prevents confusion and ensures correct id field semantics.samples/next.js/eslint.config.mjs (3)
1-3: LGTM! Modern ESLint v9+ configuration pattern.The imports follow the official ESLint v9.22+ pattern with
defineConfigandglobalIgnoresfrom "eslint/config", which is also recommended in the Next.js documentation.
5-16: Well-structured configuration with appropriate ignores.The configuration correctly uses
defineConfigto spread the Next.js configs andglobalIgnoresto explicitly override the default ignore patterns. The ignore patterns are standard for Next.js projects.
18-18: Export looks good, but note the pipeline failure.The export is correct. However, the pipeline failure indicates a TypeScript error in a route handler file that needs to be addressed separately.
The build error mentions:
Type 'typeof import(".../route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/model/[...path]">'.This suggests a Next.js version or type incompatibility in the API route handlers, not an issue with this ESLint configuration.samples/next.js/tsconfig.json (1)
1-34: The review comment is incorrect — tsconfig.json is not the cause of the pipeline failure.The tsconfig.json is correctly configured for Next.js 16.0.1 with appropriate settings (ES2017 target, bundler module resolution, strict mode, jsx: "react-jsx"). The pipeline failure is unrelated to this configuration file.
The build error stems from the route handler at
samples/next.js/app/api/model/[...path]/route.ts, which uses ZenStack'sNextRequestHandlerwrapper. The type incompatibility is between the wrapped handler and Next.js 16's route handler type requirements, not from the TypeScript configuration in tsconfig.json. This is a route handler implementation or ZenStack library compatibility issue that needs to be addressed in the route handler code, not in the TypeScript configuration.Likely an incorrect or invalid review comment.
samples/next.js/next.config.ts (1)
1-7: LGTM: Standard Next.js configuration.The configuration structure follows Next.js conventions with proper TypeScript typing.
packages/cli/package.json (1)
48-48: LGTM: Consistent with catalog-based dependency resolution.The change aligns with the workspace-wide pattern of using catalog references for shared dependencies.
packages/orm/package.json (1)
92-92: LGTM: Consistent with catalog-based dependency resolution.The change aligns with the workspace-wide pattern of using catalog references for shared dependencies.
samples/orm/package.json (2)
6-6: LGTM: Marking sample package as private.Good practice to prevent accidental publication of sample/demo packages to npm.
20-21: LGTM: Consistent with catalog-based dependency resolution.All dependency changes align with the workspace-wide catalog pattern for shared dependencies.
Also applies to: 24-24
pnpm-workspace.yaml (1)
21-25: I have the information confirming React 19.2.0 stability and TanStack Query compatibility. Let me verify the remaining concern about Next.js:React 19.2.0 and TanStack React Query 5.90.6 are compatible and stable for use with Next.js.
React 19.2.0 is an official stable release (released Oct 1, 2025). TanStack Query v5.90.6 is compatible with React 19. Next.js officially supports React 19 (stable) in both Pages Router & App Router.
No known breaking issues block this combination. Verify all third-party dependencies that may not yet list React 19 in their peer dependencies during installation.
README.md (1)
54-55: No update to documentation required—the Next.js + TanStack Query sample builds successfully.The referenced sample exists at
samples/next.js/and appears to be in proper working order. The TypeScript configuration is strict and correctly configured. The repository'sbuild-test.ymlCI workflow runs full builds, linting, and tests, which would catch any TypeScript compilation errors. No evidence of current build failures exists in the commit history, and the sample has been recently maintained with active feature development. The documentation reference to this sample in README.md is accurate and current.Likely an incorrect or invalid review comment.
samples/next.js/README.md (1)
1-7: Review comment is incorrect or outdated.The route handler implementation at
samples/next.js/app/api/model/[...path]/route.tsand the underlyingAppRouteHandlerfactory both correctly implement the Next.js 16 App Router type requirements:
AppRouteHandlerreturns(req: NextRequest, context: Context) => Promise<NextResponse>whereContext = { params: Promise<{ path: string[] }> }- This signature matches Next.js 16's
RouteHandlerConfigconstraint, which requiresparamsto bePromise<...>and handlers to returnPromise<Response>- The implementation properly awaits
context.paramsbefore accessing properties- The sample route correctly exports the handler as
DELETE,GET,PATCH,POST,PUTThe code follows the correct async API pattern for Next.js 16. No type mismatch exists based on code inspection. Without access to actual build logs or CI output, there is no evidence of the claimed build failure.
Likely an incorrect or invalid review comment.
package.json (1)
34-35: LGTM! Dependency management change is correct.The addition of Prisma as a catalog-based devDependency is consistent with the pattern used for other dependencies in this file.
packages/testtools/package.json (1)
51-51: LGTM! Catalog-based dependency resolution.The change to catalog-based resolution for @types/better-sqlite3 aligns with the broader effort across multiple packages to centralize dependency versions.
packages/plugins/policy/package.json (1)
48-48: LGTM! Consistent catalog adoption.This change mirrors the dependency resolution update in other packages.
packages/clients/tanstack-query/tsconfig.json (1)
1-7: LGTM! Standard TypeScript configuration.The configuration appropriately extends the base config and targets ESNext, which is suitable for a modern client library.
samples/next.js/postcss.config.mjs (1)
1-7: LGTM! Standard PostCSS + Tailwind configuration.The configuration correctly sets up the Tailwind CSS PostCSS plugin for the Next.js sample.
samples/next.js/app/layout.tsx (1)
1-27: This review comment is incorrect and should be dismissed.The comment claims that
samples/next.js/app/layout.tsxcontains a TypeScript error with an "API route handler," but layout.tsx is the app root layout component, not an API route handler. The actual API route handler is in a separate file atsamples/next.js/app/api/model/[...path]/route.ts, which has properly typed exports (DELETE, GET, PATCH, POST, PUT) usingNextRequestHandlerwith no apparent errors. The layout.tsx file is correctly structured, imports are properly resolved, and there are no TypeScript errors evident in the code or related files (providers.tsx, next.config.ts, tsconfig.json).Likely an incorrect or invalid review comment.
samples/next.js/app/providers.tsx (1)
1-15: Update @zenstackhq/server package for Next.js 16.0.1 compatibility or adjust handler configuration.The route handler export pattern in
samples/next.js/app/api/model/[...path]/route.tsis correct per ZenStack documentation. However, Next.js 16.0.1 introduces breaking changes that may require the workspace@zenstackhq/serverpackage to have updated type definitions. The pipeline TypeScript error indicates theNextRequestHandlerreturn type may not satisfy Next.js 16's route handler type constraint. Verify that the workspace ZenStack packages have been updated to support Next.js 16.0.1, or consider upgrading to a compatible release version from npm if the workspace package is outdated.samples/next.js/lib/db.ts (1)
6-9: DB bootstrap looks solid
Centralizing the reusableZenStackClientwith a single BetterSQLite connection keeps the sample setup clean. Nicely done.samples/next.js/app/page.tsx (1)
10-88: Client usage of the new hooks looks great
The page wiresuseModelQueriescleanly, handles empty states, and ties mutations to UI actions without leaks. Nice illustrative sample.samples/next.js/zenstack/models.ts (1)
8-17: Generated model aliases check out
The exportedUserandPostaliases match the generated schema and look correct.samples/next.js/zenstack/schema.zmodel (1)
1-25: Schema definition is consistent
The zmodel mirrors the generated TypeScript schema and looks correct for the sample.
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
There was a problem hiding this 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
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/clients/tanstack-query/src/utils/mutator.ts(1 hunks)packages/clients/tanstack-query/src/utils/nested-write-visitor.ts(1 hunks)packages/clients/tanstack-query/src/utils/query-analysis.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/clients/tanstack-query/src/utils/query-analysis.ts
- packages/clients/tanstack-query/src/utils/mutator.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/clients/tanstack-query/src/utils/nested-write-visitor.ts (3)
packages/schema/src/schema.ts (2)
FieldDef(60-75)SchemaDef(10-18)packages/clients/tanstack-query/src/utils/types.ts (3)
MaybePromise(1-1)ORMWriteActionType(19-19)ORMWriteActions(3-17)packages/common-helpers/src/enumerable.ts (1)
enumerate(9-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
🔇 Additional comments (10)
packages/clients/tanstack-query/src/utils/nested-write-visitor.ts (10)
5-93: LGTM! Well-structured type definitions.The type definitions are comprehensive and well-documented. The flexible callback return type (
boolean | object | void) provides good control over traversal continuation and payload replacement.
99-106: LGTM!Constructor and type guard are correctly implemented.
113-133: LGTM! Good normalization of payloads.The
visitmethod correctly normalizes different payload structures before passing them todoVisit, making the main visitor logic cleaner.
156-168: LGTM! Correct handling of create action.The reverse enumeration allows callbacks to safely mutate/delete items, and the sub-payload traversal correctly handles nested creates.
170-183: LGTM! Correct extraction of createMany data.Line 179 correctly extracts
data.databased on thecreateManyargument structure{ data: any[], skipDuplicates?: boolean }. The guard at line 143 ensuresdatais always truthy here.
185-227: LGTM! Correct handling of relation operations.The implementation correctly handles the various relation operation structures:
connectOrCreate: extractswhereandcreatefieldsconnect,disconnect,set: properly handle unique filters and boolean forms
229-280: LGTM! Complex update/upsert logic handled correctly.The logic properly handles multiple payload structures:
update: handles both{ where, data }and direct data formsupdateMany: extracts where and data appropriatelyupsert: visits both create and update branches, with callback control over which payloads to traverse
301-303: LGTM! Good defensive error handling.The default case properly throws an error for unhandled action types, ensuring no silent failures.
307-346: LGTM! Recursive traversal correctly implemented.The method properly:
- Handles missing field definitions defensively (line 320)
- Distinguishes between relation fields (recursing into nested actions) and plain fields (invoking field callback)
- Preserves the nesting path for context tracking
350-358: LGTM! Smart enumeration strategy.Reverse-order enumeration allows callbacks to safely mutate or delete the current item without disrupting the iteration. This is a good defensive pattern for visitor implementations.
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
samples/next.js/app/page.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
samples/next.js/app/page.tsx (2)
packages/clients/tanstack-query/src/react.ts (1)
useModelQueries(209-311)samples/next.js/zenstack/schema.ts (1)
schema(9-114)
🔇 Additional comments (4)
samples/next.js/app/page.tsx (4)
1-9: LGTM!The imports and setup are clean. The 'use client' directive is correctly placed, and the lorem-ipsum configuration is appropriate for generating post titles.
10-16: Component setup looks good.The TanStack Query hooks are used correctly. The posts query properly includes the author relation needed for rendering.
44-46: LGTM!Good UX pattern—waiting for the fetch to complete before showing the "no users" message with clear guidance.
48-74: LGTM!Clean layout with responsive design and dark mode support. The "New Post" button styling is complete, and user list rendering is safe with optional chaining.
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
There was a problem hiding this 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
♻️ Duplicate comments (2)
packages/clients/tanstack-query/src/utils/common.ts (1)
192-198: Wrap marshaled payload underdatawhen meta is present.We’re still flattening the payload whenever serialization metadata exists, so requests become
{ ...fields, meta }instead of{ data, meta }. That breaks the backend contract (and our ownunmarshal) for metadata-bearing operations, leaving them unreadable. Please restore thedatawrapper exactly as previously requested.- return JSON.stringify({ ...(data as any), meta: { serialization: meta } }); + return JSON.stringify({ data, meta: { serialization: meta } });packages/clients/tanstack-query/src/react.ts (1)
508-525: Pass the QueryCache instance, not the Query array.The
setupOptimisticUpdatefunction expects aQueryCacheinstance to call methods likefindandgetAll, but Line 514 is passingqueryClient.getQueryCache().getAll()(which returns aQuery[]). This will cause a runtime error when the optimistic update logic attempts to invoke cache methods.Apply this diff:
setupOptimisticUpdate( model, operation, schema, finalOptions, - queryClient.getQueryCache().getAll(), + queryClient.getQueryCache(), (queryKey, data) => { // update query cache queryClient.setQueryData<unknown>(queryKey, data);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
packages/clients/tanstack-query/package.json(1 hunks)packages/clients/tanstack-query/scripts/generate.ts(1 hunks)packages/clients/tanstack-query/src/react.ts(1 hunks)packages/clients/tanstack-query/src/utils/common.ts(1 hunks)packages/clients/tanstack-query/test/react-query.test.tsx(1 hunks)packages/clients/tanstack-query/test/schemas/basic/input.ts(1 hunks)packages/clients/tanstack-query/test/schemas/basic/models.ts(1 hunks)packages/clients/tanstack-query/test/schemas/basic/schema.ts(1 hunks)packages/clients/tanstack-query/test/schemas/basic/schema.zmodel(1 hunks)packages/clients/tanstack-query/vitest.config.ts(1 hunks)tests/regression/generate.ts(0 hunks)
💤 Files with no reviewable changes (1)
- tests/regression/generate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/clients/tanstack-query/package.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
packages/clients/tanstack-query/test/schemas/basic/schema.ts
🧬 Code graph analysis (5)
packages/clients/tanstack-query/test/react-query.test.tsx (3)
packages/clients/tanstack-query/src/react.ts (3)
Provider(82-82)QuerySettingsProvider(75-75)useClientQueries(228-233)packages/clients/tanstack-query/src/utils/common.ts (2)
makeUrl(211-223)getQueryKey(180-190)packages/clients/tanstack-query/test/schemas/basic/schema.ts (1)
schema(9-130)
packages/clients/tanstack-query/scripts/generate.ts (1)
packages/sdk/src/ts-schema-generator.ts (1)
TsSchemaGenerator(54-1419)
packages/clients/tanstack-query/test/schemas/basic/schema.ts (2)
packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)packages/schema/src/schema.ts (1)
SchemaDef(10-18)
packages/clients/tanstack-query/src/utils/common.ts (5)
packages/clients/tanstack-query/src/utils/serialization.ts (2)
serialize(29-32)deserialize(37-39)packages/common-helpers/src/lower-case-first.ts (1)
lowerCaseFirst(1-3)packages/clients/tanstack-query/src/utils/types.ts (1)
ORMWriteActionType(19-19)packages/clients/tanstack-query/src/utils/query-analysis.ts (2)
getMutatedModels(30-78)getReadModels(14-25)packages/clients/tanstack-query/src/utils/mutator.ts (1)
applyMutation(19-39)
packages/clients/tanstack-query/src/react.ts (3)
packages/clients/tanstack-query/src/utils/common.ts (9)
APIContext(111-126)ExtraQueryOptions(101-106)ExtraMutationOptions(81-96)makeUrl(211-223)getQueryKey(180-190)fetcher(128-159)marshal(192-199)setupInvalidation(234-255)setupOptimisticUpdate(313-357)packages/schema/src/schema.ts (2)
SchemaDef(10-18)GetModels(109-109)packages/common-helpers/src/lower-case-first.ts (1)
lowerCaseFirst(1-3)
🪛 Biome (2.1.2)
packages/clients/tanstack-query/src/react.ts
[error] 85-85: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 230-230: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 251-251: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 255-255: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 259-259: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 263-263: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 267-267: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 271-271: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 275-275: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 279-279: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 283-283: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 287-287: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 291-291: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 295-295: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 299-299: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 303-303: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 307-307: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 311-311: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 315-315: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 319-319: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 323-323: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 327-327: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 331-331: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 335-335: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 339-339: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 351-351: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 359-359: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 374-374: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 382-382: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 400-400: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 404-404: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 430-430: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 434-434: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 474-474: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 475-475: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 496-496: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
[error] 528-528: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
This is the call path until the hook.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: claude-review
🔇 Additional comments (2)
packages/clients/tanstack-query/src/react.ts (1)
228-342: Static analysis false positives: factory pattern is valid.Biome is flagging numerous
useHookAtTopLevelerrors for this file, but most are false positives. The pattern here uses factory functions (useClientQueries,useModelQueries) that return objects containing hook implementations. The actual hooks (useInternalQuery,useInternalSuspenseQuery, etc.) properly call React hooks at the top level. Consumers will invoke these returned hooks at the top level of their components, which is the correct pattern for dynamic/configurable hooks.The only legitimate hook violation is the conditional
useContextcall at line 496, which is addressed separately.packages/clients/tanstack-query/test/schemas/basic/input.ts (1)
1-70: Generated code looks consistent.This is an auto-generated file with consistent type alias patterns for all three models (User, Post, Category). The type definitions appear correct and follow a uniform structure.
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/clients/tanstack-query/test/react-query.test.tsx(1 hunks)packages/clients/tanstack-query/vitest.config.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/clients/tanstack-query/test/react-query.test.tsx (3)
packages/clients/tanstack-query/src/react.ts (3)
Provider(82-82)QuerySettingsProvider(75-75)useClientQueries(228-233)packages/clients/tanstack-query/src/utils/common.ts (1)
getQueryKey(180-190)packages/clients/tanstack-query/test/schemas/basic/schema.ts (1)
schema(9-130)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
|
Claude finished @ymc9's task —— View job Code Review CompleteI've completed a comprehensive review of the TanStack Query integration for ZenStack v3. Here's my detailed feedback: Todo List:
Overall AssessmentThis is a solid implementation of TanStack Query integration for ZenStack v3. The code demonstrates good TypeScript practices and follows TanStack Query conventions well. However, there are several areas for improvement: Code Quality & Best Practices✅ Strengths:
|
Summary by CodeRabbit