Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Oct 1, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

📝 Walkthrough

Walkthrough

Updates span: REST API now parses fields[] for partial field selection and integrates it into select/include flows; delegate enhancement injects nested where clauses; attribute arg value becomes optional across runtime and generator; build script loads .env files; adds tests for partial fields and a delegation regression; bumps JetBrains plugin version.

Changes

Cohort / File(s) Summary
REST partial field selection
packages/server/src/api/rest/index.ts, packages/server/tests/api/rest-partial.test.ts
Adds buildPartialSelect for fields[] parsing, merges partial selects into Prisma payloads across read paths, introduces duplicatedFieldsParameter error, updates relation select construction; comprehensive tests cover sparse fieldsets and nested relations.
Delegate nested where injection
packages/runtime/src/enhancements/node/delegate.ts
After injecting nested delegate select/include, now also injects where clauses from nested delegate payloads.
Model metadata arg typing
packages/runtime/src/cross/model-meta.ts, packages/sdk/src/model-meta-generator.ts
Makes RuntimeAttribute.args value optional (value?: unknown); generator imports ModelMeta as type and annotates metadata; getAttributes now allows optional argument values.
Build env loading
packages/schema/build/bundle.js
Replaces path import with dotenv configuration, loading ./.env.local then ./.env.
Regression test: delegation include/count
tests/regression/tests/issue-2246.test.ts
Adds test verifying nested includes, filtered counts, and queries in delegated/inherited models.
IDE plugin version bump
packages/ide/jetbrains/build.gradle.kts
Bumps version from 2.19.1 to 2.19.2.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor C as Client
  participant RH as REST Handler
  participant PS as buildPartialSelect
  participant RS as buildRelationSelect
  participant DB as Prisma

  C->>RH: GET /resources?fields[User]=id,name&include=posts
  RH->>PS: parse fields[User]
  PS-->>RH: { select: { id: true, name: true } }
  RH->>RS: build nested relation select/include (with query)
  RS-->>RH: include/select with nested partials/default ids
  RH->>DB: findMany({ select/include merged })
  DB-->>RH: rows + related
  RH-->>C: JSON: data + included (projected fields)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning No pull request description was provided, so there is no context or summary of the changeset, making the description entirely missing and unhelpful for review. Please add a descriptive summary that outlines the purpose of the merge, the significant changes included, and any relevant details to help reviewers understand and evaluate the pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The pull request title “merge dev to main (v2.19.2)” is generic and primarily describes the branch action and version bump without summarizing the functional changes introduced, making it too vague to convey the main improvements in the changeset. Please update the title to succinctly summarize the key changes or features added, such as the introduction of sparse field selection in the REST API and the version bump to 2.19.2.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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.

Copy link
Contributor

@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: 2

🧹 Nitpick comments (1)
packages/server/tests/api/rest-partial.test.ts (1)

377-471: Fix typo in test names.

Test names contain "efect" which should be "affect" (lines 377, 412, 445).

Apply this diff to fix the typos:

-        it('does not efect toplevel filtering', async () => {
+        it('does not affect toplevel filtering', async () => {

-        it('does not efect toplevel sorting', async () => {
+        it('does not affect toplevel sorting', async () => {

-        it('does not efect toplevel pagination', async () => {
+        it('does not affect toplevel pagination', async () => {

Otherwise, the test coverage is comprehensive and validates the feature well across multiple scenarios including interactions with existing functionality.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be9c553 and d543a0d.

⛔ Files ignored due to path filters (13)
  • package.json is excluded by !**/*.json
  • packages/ide/jetbrains/package.json is excluded by !**/*.json
  • packages/language/package.json is excluded by !**/*.json
  • packages/misc/redwood/package.json is excluded by !**/*.json
  • packages/plugins/openapi/package.json is excluded by !**/*.json
  • packages/plugins/swr/package.json is excluded by !**/*.json
  • packages/plugins/tanstack-query/package.json is excluded by !**/*.json
  • packages/plugins/trpc/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • packages/server/package.json is excluded by !**/*.json
  • packages/testtools/package.json is excluded by !**/*.json
📒 Files selected for processing (8)
  • packages/ide/jetbrains/build.gradle.kts (1 hunks)
  • packages/runtime/src/cross/model-meta.ts (1 hunks)
  • packages/runtime/src/enhancements/node/delegate.ts (1 hunks)
  • packages/schema/build/bundle.js (1 hunks)
  • packages/sdk/src/model-meta-generator.ts (2 hunks)
  • packages/server/src/api/rest/index.ts (12 hunks)
  • packages/server/tests/api/rest-partial.test.ts (1 hunks)
  • tests/regression/tests/issue-2246.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
tests/regression/tests/issue-2246.test.ts (1)
packages/testtools/src/schema.ts (1)
  • loadSchema (172-248)
packages/server/src/api/rest/index.ts (1)
packages/runtime/src/local-helpers/lower-case-first.ts (1)
  • lowerCaseFirst (1-3)
packages/server/tests/api/rest-partial.test.ts (2)
packages/testtools/src/schema.ts (1)
  • loadSchema (172-248)
packages/server/src/api/rest/index.ts (2)
  • makeHandler (2101-2104)
  • makeHandler (2106-2106)
packages/sdk/src/model-meta-generator.ts (1)
packages/sdk/src/code-gen.ts (1)
  • FastWriter (90-131)
⏰ 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). (6)
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (12)
packages/schema/build/bundle.js (1)

5-6: LGTM! Environment configuration loaded correctly.

The dotenv configuration correctly loads .env.local first (for local overrides) and then .env (for defaults). This is a standard pattern for managing environment-specific configuration.

packages/runtime/src/enhancements/node/delegate.ts (1)

231-233: LGTM! Nested where clause injection for delegate models.

Correctly propagates where conditions into nested delegate hierarchies after the select/include hierarchy is injected. This ensures filtering works properly for nested delegate relations.

packages/sdk/src/model-meta-generator.ts (3)

83-88: LGTM! Type-only import added for explicit typing.

Adding a type-only import of ModelMeta and using it to explicitly type the metadata variable improves code clarity without affecting the runtime bundle.


96-96: LGTM! Explicit type annotation improves clarity.

Explicitly typing metadata as ModelMeta is clearer than relying on type inference from writer.result.


374-374: LGTM! Optional value aligns with runtime type changes.

Making the value property optional in attribute args aligns with the corresponding change in packages/runtime/src/cross/model-meta.ts and correctly handles cases where exprToValue() returns undefined.

tests/regression/tests/issue-2246.test.ts (1)

1-82: LGTM! Comprehensive regression test for nested delegate filtering.

This test thoroughly validates nested relation includes, counts, and filtering across a delegate model hierarchy. It correctly tests:

  • Nested where clauses in includes (line 52-55)
  • _count with filtered relations (line 63)
  • Both positive and negative cases

The test ensures the delegate enhancement changes work correctly with nested filtering scenarios.

packages/server/src/api/rest/index.ts (5)

180-183: LGTM!

The new error type for duplicate field parameters is well-defined and consistent with existing error patterns.


519-541: LGTM!

The integration of partial field selection in processSingleRead correctly handles the merge of select and include options, following Prisma's constraint that select and include cannot coexist.


577-594: LGTM!

The partial select integration correctly avoids overriding existing select objects from includes and applies field filtering to related resources.


739-761: LGTM!

The partial field selection integration in processCollectionRead mirrors the logic in processSingleRead, maintaining consistency across the codebase.


1861-1919: LGTM!

The enhancement to buildRelationSelect properly propagates partial field selection into nested relations while maintaining backward compatibility. The logic correctly handles both intermediate and terminal relations in the include path.

packages/server/tests/api/rest-partial.test.ts (1)

1-62: LGTM!

The test setup is well-structured with proper schema definition, test isolation via database resets, and clean dependency injection through the handler wrapper.

@ymc9 ymc9 enabled auto-merge October 1, 2025 02:28
@ymc9 ymc9 disabled auto-merge October 1, 2025 02:28
@ymc9 ymc9 merged commit dfe721c into main Oct 1, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants