fix(tanstack,swr): create/upsert hooks shouldn't be generated for delegate models#1567
fix(tanstack,swr): create/upsert hooks shouldn't be generated for delegate models#1567
Conversation
WalkthroughWalkthroughThe recent updates implement checks for delegate models to exclude specific operations like Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SWRPlugin
participant TanstackQueryPlugin
participant Model
User ->> SWRPlugin: Generate SWR hooks
SWRPlugin ->> SWRPlugin: Check if model is a delegate model
alt Delegate Model
SWRPlugin -->> User: Skip create and upsert operations
else Non-Delegate Model
SWRPlugin ->> Model: Generate create and upsert hooks
User -->> Model: Use generated hooks
end
User ->> TanstackQueryPlugin: Generate Tanstack Query hooks
TanstackQueryPlugin ->> TanstackQueryPlugin: Check if model is a delegate model
alt Delegate Model
TanstackQueryPlugin -->> User: Skip create and upsert operations
else Non-Delegate Model
TanstackQueryPlugin ->> Model: Generate create and upsert hooks
User -->> Model: Use generated hooks
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/plugins/swr/src/generator.ts (3 hunks)
- packages/plugins/tanstack-query/src/generator.ts (3 hunks)
- tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts (1 hunks)
Additional comments not posted (8)
tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts (2)
26-40: LGTM! Ensure schema and dependencies are correct.The
swrtest case is correctly added, defining a schema and loading it with the required dependencies.Verify that the schema and dependencies (
@zenstackhq/swrandswr) are correctly configured and available.
49-55: LGTM! Ensure additional dependencies are correct.The
trpctest case has been correctly modified to includegenerateClientHelpers = 'react'and add@trpc/react-querytoextraDependencies.Verify that the additional dependencies (
@trpc/react-query) are correctly configured and available.packages/plugins/swr/src/generator.ts (3)
81-85: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
createoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.
91-91: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
createManyoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.
144-144: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
upsertoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.packages/plugins/tanstack-query/src/generator.ts (3)
345-349: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
createoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.
354-354: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
createManyoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.
428-428: LGTM! EnsureisDelegateModelfunction is correctly integrated.The
upsertoperation is correctly excluded for delegate models.Verify that the
isDelegateModelfunction is correctly integrated and functioning as expected.
No description provided.