Skip to content

Conversation

@Diluka
Copy link
Contributor

@Diluka Diluka commented Dec 5, 2025

Summary

Fixes #410 - Federation referenceBy broken since v9.2.0

Problem

The auto-generated @ResolveReference() method fails in Apollo Federation because the representation parameter is undefined. This regression was introduced in v9.2.0 when DataLoader support was added with @Context() and @InjectDataLoaderConfig() parameter decorators.

Root Cause: @nestjs/graphql's @ResolveReference() decorator has known incompatibilities with parameter decorators (see NestJS issues #945, #2127). When parameter decorators are present without a decorator on the first parameter, it becomes undefined.

Solution

Add @Parent() decorator to the representation parameter in resolveReference() method:

// Before (broken)
async resolveReference(
  representation: RepresentationType,
  @Context() context: ExecutionContext,
  ...
)

// After (fixed)
async resolveReference(
  @Parent() representation: RepresentationType,
  @Context() context: ExecutionContext,
  ...
)

Also fixed a type consistency issue in ReferenceLoader where Map keys needed String() conversion for consistent lookups.

Changes

  1. packages/query-graphql/src/resolvers/reference.resolver.ts

    • Added @Parent() decorator to representation parameter
  2. packages/query-graphql/src/loader/reference.loader.ts

    • Changed Map type to Map<string, DTO> for consistent key handling
    • Added String(id) conversion for Map operations
  3. packages/query-graphql/tests/integration/federation-n1/federation-reference.spec.ts (NEW)

    • Added true Federation integration test using ApolloFederationDriver
    • Tests _entities query which simulates Gateway requests to subgraph
    • Validates the fix works correctly

Testing

The new integration test (federation-reference.spec.ts) validates:

  • ✅ TodoList reference resolution via _entities query
  • ✅ TodoItem reference resolution via _entities query
  • ✅ Batch multiple references efficiently (DataLoader)
  • ✅ Mixed entity types in single _entities query
  • ✅ ID type handling (number vs string)
  • ✅ Error handling for non-existent entities
  • ✅ SDL validation with @key directive

Verification: Removing @Parent() causes all _entities tests to fail with Cannot read properties of undefined (reading 'id') - the exact error reported in #410.

Checklist

  • Code follows the project's coding standards
  • Changes have been tested locally
  • New tests added for the fix
  • All existing tests pass

Summary by CodeRabbit

  • New Features

    • Added a self-contained Federation V2 end-to-end test environment and a CI job to run it.
  • Bug Fixes

    • Fixed federation reference resolution when using context/injected data loaders.
    • Normalized ID handling by coercing IDs to strings for consistent cross-service reference matching.
  • Tests

    • Added comprehensive E2E and integration tests covering reference resolution, ID formats, batching, and error scenarios.
  • Documentation

    • Added README describing the Federation V2 E2E setup and quick start.

✏️ Tip: You can customize this high-level summary in your review settings.

This example successfully reproduces the bug where @ResolveReference()
receives undefined for the representation parameter when @context()
and @InjectDataLoaderConfig() decorators are present.

Test environment includes:
- user-service: User entity with referenceBy config
- todo-service: TodoItem with @reference to User
- gateway: Apollo Gateway composing federated schema
- PostgreSQL database

The bug is triggered when creating a TodoItem with assigneeId and
requesting the assignee field, causing:
'Cannot read properties of undefined (reading id)'

Issue: TriPSs#410
- Add tag-service with UUID primary key to test string ID type
- Update todo-service to reference both User (numeric ID) and Tag (UUID ID)
- Update gateway to include tag-service subgraph
- Update README with fix documentation and expected results
- Add seeder data for tags with fixed UUIDs

This validates the fix for issue TriPSs#410 works with different ID types.
…ederation TriPSs#410

- Add @parent() decorator to representation parameter in reference.resolver.ts
  Without this decorator, NestJS does not inject the representation object
- Use String(id) for Map key comparison in reference.loader.ts
  Federation representation.id may be number while entity.id is string (or vice versa)
- Add e2e-test service with Jest test suite
- Validate Federation reference resolution
- Test numeric ID (User) and UUID string ID (Tag)
- Verify issue TriPSs#410 fix works correctly
- Use docker compose profile 'test' for test runner
- Run Federation V2 E2E tests in CI
- Use docker/setup-compose-action to ensure Docker Compose available
- Validates issue TriPSs#410 fix with Docker Compose
- Shows logs on failure for debugging
- Add true Federation integration test that simulates Gateway requests
- Use ApolloFederationDriver to create real Federation subgraph
- Add @directive('@key(fields: "id")') to DTOs for Federation entity support
- Test cases cover:
  - Single entity reference resolution (Issue TriPSs#410 validation)
  - Multiple entities batching (DataLoader)
  - Mixed entity types in single query
  - ID type handling (number vs string)
  - Error cases (non-existent, missing key)
  - SDL validation with @key directive

Related to: Issue TriPSs#410
@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Walkthrough

Adds a Federation V2 end-to-end test environment (multi-service Docker Compose, gateway and subgraphs, E2E runner) and fixes federation reference resolution by annotating the resolveReference representation with @Parent() and coercing reference IDs to strings for consistent loader/Map lookups.

Changes

Cohort / File(s) Summary
CI Workflow
\ .github/workflows/test.yml ``
New federation-e2e-test job that builds images, runs Docker Compose with the test profile, runs the E2E tests, and prints logs on failure.
E2E Project Root
\ examples/federation-v2-e2e/.dockerignore `, ` examples/federation-v2-e2e/.gitignore `, ` examples/federation-v2-e2e/README.md `, ` examples/federation-v2-e2e/docker-compose.yml ``
New example directory with docs, ignore rules and Docker Compose orchestration for postgres, user/tag/todo services, gateway, and e2e-test.
E2E Test Runner
examples/federation-v2-e2e/e2e-test
\ examples/federation-v2-e2e/e2e-test/package.json `, ` examples/federation-v2-e2e/e2e-test/jest.config.js `, ` examples/federation-v2-e2e/e2e-test/tsconfig.json `, ` examples/federation-v2-e2e/e2e-test/Dockerfile `, ` examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts ``
New Jest/TypeScript e2e project and Docker image with tests exercising federation _entities resolution, mixed ID formats, batching, and Issue #410 scenarios.
Gateway Service
\ examples/federation-v2-e2e/gateway/* ``
New NestJS Apollo Gateway project (AppModule, main.ts, Dockerfile, configs) composing subgraphs via IntrospectAndCompose.
User Subgraph
\ examples/federation-v2-e2e/user-service/* ``
New user subgraph: DTOs, entity, inputs, module, seeder, entrypoint, Dockerfile, and TS/Nest configs.
Tag Subgraph
\ examples/federation-v2-e2e/tag-service/* ``
New tag subgraph with UUID IDs: DTO, entity, inputs, module, seeder, Dockerfile, and configs.
Todo Subgraph
\ examples/federation-v2-e2e/todo-service/* ``
New todo subgraph with federation references to User/Tag: DTOs, entity, inputs, module, seeder, Dockerfile, and configs.
DB Init Script
\ examples/federation-v2-e2e/init-scripts/01-create-databases.sql ``
SQL script creating three PostgreSQL users/databases and granting privileges for the example environment.
Build / Packaging
\ examples/federation-v2-e2e//Dockerfile `, ` examples/federation-v2-e2e//tsconfig.json `, ` examples/federation-v2-e2e/*/package.json ``
Added multi-stage Dockerfiles, TypeScript configs and package manifests for gateway, subgraphs and e2e runner to support building and test execution.
Core Library Fixes
\ packages/query-graphql/src/resolvers/reference.resolver.ts `, ` packages/query-graphql/src/loader/reference.loader.ts ``
Added @Parent() decorator to the resolveReference representation parameter; changed reference loader Map to Map<string, DTO> and coerced IDs with String(id) on insertion and lookup.
Integration Tests / Fixtures
\ packages/query-graphql/tests/integration/federation-n1/* ``
Added/updated federation integration tests and DTO directives to cover _entities resolution, batching, mixed ID handling, and adjusted fixture comments.
Jest Config
\ jest.e2e.ts ``
Added testPathIgnorePatterns to exclude /node_modules/ and the federation example directory from e2e test runs.
Repository manifest
\ package.json ``
Added graphql-request as a devDependency (used by e2e tests).
sequenceDiagram
    participant Client
    participant Gateway
    participant TodoSvc as Todo Service
    participant UserSvc as User Service
    participant TagSvc as Tag Service
    participant DB as PostgreSQL

    Client->>Gateway: Query todoItems (includes assignee/tag)
    Gateway->>TodoSvc: Fetch todoItems
    TodoSvc->>DB: SELECT todo_items
    DB-->>TodoSvc: rows
    TodoSvc-->>Gateway: TodoItems with assigneeId/tagId

    Gateway->>UserSvc: _entities (representations for User)
    note right of UserSvc `#lightblue`: resolveReference receives representation via `@Parent`()\nLoader lookups use String(id)
    UserSvc->>DB: SELECT users WHERE id IN (...)
    DB-->>UserSvc: rows
    UserSvc-->>Gateway: Resolved User objects

    Gateway->>TagSvc: _entities (representations for Tag)
    note right of TagSvc `#lightblue`: resolveReference receives representation via `@Parent`()\nUUIDs coerced to strings for lookup
    TagSvc->>DB: SELECT tags WHERE id IN (...)
    DB-->>TagSvc: rows
    TagSvc-->>Gateway: Resolved Tag objects

    Gateway-->>Client: Final response with nested assignee & tag
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Files/areas needing extra attention:
    • packages/query-graphql/src/resolvers/reference.resolver.ts — confirm @Parent() works across supported @nestjs/graphql versions and codegen paths.
    • packages/query-graphql/src/loader/reference.loader.ts — verify String coercion preserves semantics for numeric IDs and maintains batching/order.
    • examples/federation-v2-e2e/docker-compose.yml and service Dockerfiles — validate healthchecks, depends_on sequencing, and multi-stage packaging in the monorepo build context.
    • examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts — ensure tests reliably exercise _entities resolution, mixed ID types, batching, and failure cases in CI.

Poem

🐰 I nibbled at the missing Parent line,

now representations hop back fine.
IDs wear strings and find their home,
loaders match them, no more roam.
Tests bound back — federation's fine.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR introduces a complete federation-v2-e2e example environment including Docker setup, services, and E2E tests. While comprehensive for validation, these additions extend beyond the minimal fix scope of #410. Consider whether the federation-v2-e2e example directory is necessary for this PR or should be addressed separately as test infrastructure.
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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary fix: adding @parent() decorator to resolveReference for Federation issue #410.
Linked Issues check ✅ Passed The PR addresses all coding objectives from issue #410: fixing the @parent() decorator in reference.resolver.ts, updating reference.loader.ts for string-based Map keys, adding comprehensive federation integration tests, and restoring correct representation parameter handling.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b44ac81 and edf9fc4.

📒 Files selected for processing (1)
  • packages/query-graphql/__tests__/integration/federation-n1/fixtures/test-data.ts (1 hunks)
⏰ 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). (5)
  • GitHub Check: e2e-test (20.x, postgres)
  • GitHub Check: e2e-test (21.x, mysql)
  • GitHub Check: e2e-test (20.x, mysql)
  • GitHub Check: e2e-test (21.x, postgres)
  • GitHub Check: federation-e2e-test

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.

@nx-cloud
Copy link

nx-cloud bot commented Dec 5, 2025

View your CI Pipeline Execution ↗ for commit edf9fc4

Command Status Duration Result
nx run-many --target=e2e --all ✅ Succeeded 2m 4s View ↗
nx run-many --target=test --all ✅ Succeeded 44s View ↗
nx run-many --target=lint --all ✅ Succeeded 17s View ↗
nx run-many --target=build --all ✅ Succeeded 4s View ↗
nx run workspace:version ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-05 08:10:56 UTC

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 (12)
examples/federation-v2-e2e/user-service/Dockerfile (3)

30-30: Consider building only required packages instead of --all.

Line 30 uses yarn nx run-many --target=build --all, which builds every package in the monorepo. For this user-service image, only core, query-graphql, and query-typeorm are needed. Building only these packages could reduce build time and image size.

Apply this diff to reduce build scope:

-RUN yarn nx run-many --target=build --all
+RUN yarn nx run-many --target=build --projects=@ptc-org/nestjs-query-core,@ptc-org/nestjs-query-graphql,@ptc-org/nestjs-query-typeorm

Note: Verify the project names match your nx.json configuration.


56-59: Consolidate npm install commands for clarity.

The three separate npm install commands in stage 2 can be consolidated into a single invocation for better readability and atomicity.

Apply this diff to consolidate the install commands:

-RUN npm install ./packages/ptc-org-nestjs-query-core-*.tgz \
-    ./packages/ptc-org-nestjs-query-graphql-*.tgz \
-    ./packages/ptc-org-nestjs-query-typeorm-*.tgz \
-    && npm install
+RUN npm install ./packages/ptc-org-nestjs-query-core-*.tgz \
+           ./packages/ptc-org-nestjs-query-graphql-*.tgz \
+           ./packages/ptc-org-nestjs-query-typeorm-*.tgz

This removes the separate npm install call (the dependencies specified in package.json are installed along with the tarballs).


45-73: Consider running the application as a non-root user.

For improved security posture, create a non-root user in stage 2 and run the application with that user.

Apply this diff to add a non-root user:

 FROM node:22
 
 WORKDIR /app
+
+# Create a non-root user to run the application
+RUN useradd -m -u 1001 appuser
 
 # Copy built packages from builder stage
 COPY --from=builder /build/dist/*.tgz ./packages/
@@ -68,6 +73,8 @@ RUN npm run build
 # Expose port
 EXPOSE 3000
 
+# Run as non-root user
+USER appuser
+
 # Start the service
 CMD ["node", "dist/main.js"]

Note: Ensure file ownership is set correctly (e.g., chown -R appuser:appuser /app) after copying files if needed.

examples/federation-v2-e2e/todo-service/Dockerfile (1)

56-59: Minor optimization: combine npm install commands.

Lines 56–59 perform two separate npm install operations (first for local tarballs, then a global npm install). Consider combining these into a single command to reduce image layer count and build time.

-RUN npm install ./packages/ptc-org-nestjs-query-core-*.tgz \
-    ./packages/ptc-org-nestjs-query-graphql-*.tgz \
-    ./packages/ptc-org-nestjs-query-typeorm-*.tgz \
-    && npm install
+RUN npm install ./packages/ptc-org-nestjs-query-core-*.tgz \
+    ./packages/ptc-org-nestjs-query-graphql-*.tgz \
+    ./packages/ptc-org-nestjs-query-typeorm-*.tgz

Note: The second npm install (without arguments) is redundant if the service's package.json lists no additional production dependencies beyond the local packages.

examples/federation-v2-e2e/init-scripts/01-create-databases.sql (1)

1-12: Consider dropping SUPERUSER for test roles

For an isolated Dockerized e2e environment this is acceptable, but WITH SUPERUSER is more powerful than needed. You can generally create non-superusers and make them owners of their respective databases (or grant needed privileges) to follow least-privilege, even in tests.

examples/federation-v2-e2e/tag-service/src/main.ts (1)

6-13: Consider adding error handling to the bootstrap function.

The bootstrap function lacks error handling, which could result in uncaught promise rejections if the application fails to start. For test infrastructure, this might be acceptable, but adding basic error handling would improve debuggability.

Consider applying this diff:

 async function bootstrap() {
   const app = await NestFactory.create(AppModule)
   const port = process.env.PORT || 3000
   await app.listen(port)
   Logger.log(`Tag service running on port ${port}`)
 }
 
-bootstrap()
+bootstrap().catch((err) => {
+  Logger.error('Failed to start tag service', err)
+  process.exit(1)
+})
examples/federation-v2-e2e/gateway/src/main.ts (2)

8-8: Consider using an environment variable for the port.

The gateway uses a hardcoded port (3000) while the tag-service uses process.env.PORT || 3000. For consistency across the e2e environment and deployment flexibility, consider using an environment variable here as well.

Apply this diff:

-  await app.listen(3000)
-  console.log('Apollo Gateway running on port 3000')
+  const port = process.env.PORT || 3000
+  await app.listen(port)
+  console.log(`Apollo Gateway running on port ${port}`)

5-12: Consider adding error handling to the bootstrap function.

Similar to the tag-service, the bootstrap function lacks error handling. Adding basic error handling would improve debuggability if the gateway fails to start.

Consider applying this diff:

-void bootstrap()
+void bootstrap().catch((err) => {
+  console.error('Failed to start gateway', err)
+  process.exit(1)
+})
examples/federation-v2-e2e/tag-service/package.json (1)

1-39: Consider marking the tag-service package as private

Since this looks like an internal E2E/example package, you may want to add "private": true to avoid accidental publishing to npm; everything else in the manifest looks fine for its purpose.

 {
   "name": "tag-service",
   "version": "1.0.0",
+  "private": true,
   "main": "dist/main.js",
   "scripts": {
examples/federation-v2-e2e/gateway/tsconfig.json (1)

1-23: TS config is fine; optionally consider sharing settings via a base config

These compiler options are reasonable for the gateway and should work as expected. If the repo already has a root/base tsconfig, you might consider using extends here to keep compiler settings consistent across services and reduce duplication, but it’s not required.

examples/federation-v2-e2e/docker-compose.yml (1)

1-127: Compose topology is well-structured; just ensure healthcheck tooling matches your images

The service graph (Postgres → subgraphs → gateway → e2e-test) and healthcheck-based depends_on wiring look good for reliably running the federation E2E tests. One thing to double-check is that each built service image includes curl; otherwise the GraphQL-based healthchecks will fail even if the app is healthy. If any image lacks curl, consider installing it there or switching the healthchecks to a simpler built-in mechanism (e.g., Node-based HTTP check or another available CLI).

packages/query-graphql/__tests__/integration/federation-n1/federation-reference.spec.ts (1)

302-305: Consider using a more flexible error assertion.

The assertion toContain('Unable to find TodoList') assumes a specific error message format. If the error message changes, this test will break. Consider checking for a more stable indicator (e.g., error code, or simply that an error exists and the data is null/incomplete).

That said, this is acceptable for an integration test validating expected behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd2f83 and 0beecae.

⛔ Files ignored due to path filters (5)
  • examples/federation-v2-e2e/e2e-test/package-lock.json is excluded by !**/package-lock.json
  • examples/federation-v2-e2e/gateway/package-lock.json is excluded by !**/package-lock.json
  • examples/federation-v2-e2e/tag-service/package-lock.json is excluded by !**/package-lock.json
  • examples/federation-v2-e2e/todo-service/package-lock.json is excluded by !**/package-lock.json
  • examples/federation-v2-e2e/user-service/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (58)
  • .github/workflows/test.yml (1 hunks)
  • examples/federation-v2-e2e/.dockerignore (1 hunks)
  • examples/federation-v2-e2e/.gitignore (1 hunks)
  • examples/federation-v2-e2e/README.md (1 hunks)
  • examples/federation-v2-e2e/docker-compose.yml (1 hunks)
  • examples/federation-v2-e2e/e2e-test/Dockerfile (1 hunks)
  • examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts (1 hunks)
  • examples/federation-v2-e2e/e2e-test/jest.config.js (1 hunks)
  • examples/federation-v2-e2e/e2e-test/package.json (1 hunks)
  • examples/federation-v2-e2e/e2e-test/tsconfig.json (1 hunks)
  • examples/federation-v2-e2e/gateway/Dockerfile (1 hunks)
  • examples/federation-v2-e2e/gateway/nest-cli.json (1 hunks)
  • examples/federation-v2-e2e/gateway/package.json (1 hunks)
  • examples/federation-v2-e2e/gateway/src/app.module.ts (1 hunks)
  • examples/federation-v2-e2e/gateway/src/main.ts (1 hunks)
  • examples/federation-v2-e2e/gateway/tsconfig.json (1 hunks)
  • examples/federation-v2-e2e/init-scripts/01-create-databases.sql (1 hunks)
  • examples/federation-v2-e2e/tag-service/Dockerfile (1 hunks)
  • examples/federation-v2-e2e/tag-service/nest-cli.json (1 hunks)
  • examples/federation-v2-e2e/tag-service/package.json (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/app.module.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/main.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/tag/tag.dto.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/tag/tag.entity.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/tag/tag.input.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/tag/tag.module.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/src/tag/tag.seeder.ts (1 hunks)
  • examples/federation-v2-e2e/tag-service/tsconfig.json (1 hunks)
  • examples/federation-v2-e2e/todo-service/Dockerfile (1 hunks)
  • examples/federation-v2-e2e/todo-service/nest-cli.json (1 hunks)
  • examples/federation-v2-e2e/todo-service/package.json (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/app.module.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/main.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/tag-reference.dto.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.entity.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.input.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.module.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.seeder.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/src/todo-item/user-reference.dto.ts (1 hunks)
  • examples/federation-v2-e2e/todo-service/tsconfig.json (1 hunks)
  • examples/federation-v2-e2e/user-service/Dockerfile (1 hunks)
  • examples/federation-v2-e2e/user-service/nest-cli.json (1 hunks)
  • examples/federation-v2-e2e/user-service/package.json (1 hunks)
  • examples/federation-v2-e2e/user-service/src/app.module.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/main.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/user/user.dto.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/user/user.entity.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/user/user.input.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/user/user.module.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/src/user/user.seeder.ts (1 hunks)
  • examples/federation-v2-e2e/user-service/tsconfig.json (1 hunks)
  • packages/query-graphql/__tests__/integration/federation-n1/dtos/todo-item.dto.ts (1 hunks)
  • packages/query-graphql/__tests__/integration/federation-n1/dtos/todo-list.dto.ts (1 hunks)
  • packages/query-graphql/__tests__/integration/federation-n1/federation-reference.spec.ts (1 hunks)
  • packages/query-graphql/__tests__/integration/federation-n1/fixtures/test-data.ts (1 hunks)
  • packages/query-graphql/src/loader/reference.loader.ts (1 hunks)
  • packages/query-graphql/src/resolvers/reference.resolver.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (18)
examples/federation-v2-e2e/todo-service/src/todo-item/tag-reference.dto.ts (2)
examples/federation-v2-e2e/tag-service/src/tag/tag.dto.ts (1)
  • ObjectType (4-22)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1)
  • ObjectType (7-38)
examples/federation-v2-e2e/user-service/src/app.module.ts (4)
examples/federation-v2-e2e/gateway/src/app.module.ts (1)
  • Module (6-22)
examples/federation-v2-e2e/user-service/src/user/user.module.ts (1)
  • Module (11-32)
examples/federation-v2-e2e/todo-service/src/app.module.ts (1)
  • Module (8-29)
tools/actions/set-master-vars/src/index.js (1)
  • process (4-4)
examples/federation-v2-e2e/user-service/src/user/user.seeder.ts (1)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.seeder.ts (1)
  • Injectable (36-63)
examples/federation-v2-e2e/tag-service/src/tag/tag.module.ts (2)
examples/federation-v2-e2e/gateway/src/app.module.ts (1)
  • Module (6-22)
examples/federation-v2-e2e/tag-service/src/app.module.ts (1)
  • Module (8-29)
examples/federation-v2-e2e/todo-service/src/todo-item/user-reference.dto.ts (2)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1)
  • ObjectType (7-38)
examples/federation-v2-e2e/user-service/src/user/user.dto.ts (1)
  • ObjectType (4-21)
examples/federation-v2-e2e/tag-service/src/tag/tag.entity.ts (1)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.entity.ts (1)
  • Entity (3-29)
examples/federation-v2-e2e/tag-service/src/tag/tag.dto.ts (2)
examples/federation-v2-e2e/todo-service/src/todo-item/tag-reference.dto.ts (1)
  • ObjectType (8-13)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1)
  • ObjectType (7-38)
examples/federation-v2-e2e/user-service/src/user/user.input.ts (1)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.input.ts (2)
  • InputType (3-16)
  • InputType (18-31)
examples/federation-v2-e2e/tag-service/src/app.module.ts (3)
examples/federation-v2-e2e/gateway/src/app.module.ts (1)
  • Module (6-22)
examples/federation-v2-e2e/tag-service/src/tag/tag.module.ts (1)
  • Module (11-31)
tools/actions/set-master-vars/src/index.js (1)
  • process (4-4)
packages/query-graphql/__tests__/integration/federation-n1/federation-reference.spec.ts (1)
packages/query-graphql/__tests__/integration/federation-n1/fixtures/test-data.ts (1)
  • createTestData (7-35)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.entity.ts (1)
examples/federation-v2-e2e/tag-service/src/tag/tag.entity.ts (1)
  • Entity (3-20)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.module.ts (1)
examples/federation-v2-e2e/user-service/src/user/user.module.ts (1)
  • Module (11-32)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.seeder.ts (2)
examples/federation-v2-e2e/tag-service/src/tag/tag.seeder.ts (1)
  • Injectable (15-42)
examples/federation-v2-e2e/user-service/src/user/user.seeder.ts (1)
  • Injectable (14-41)
examples/federation-v2-e2e/user-service/src/user/user.entity.ts (1)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.entity.ts (1)
  • Entity (3-29)
examples/federation-v2-e2e/tag-service/src/tag/tag.seeder.ts (1)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.seeder.ts (1)
  • Injectable (36-63)
examples/federation-v2-e2e/user-service/src/user/user.dto.ts (2)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1)
  • ObjectType (7-38)
examples/federation-v2-e2e/todo-service/src/todo-item/user-reference.dto.ts (1)
  • ObjectType (4-9)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.input.ts (1)
examples/federation-v2-e2e/user-service/src/user/user.input.ts (2)
  • InputType (3-10)
  • InputType (12-19)
examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (4)
examples/federation-v2-e2e/tag-service/src/tag/tag.dto.ts (1)
  • ObjectType (4-22)
examples/federation-v2-e2e/todo-service/src/todo-item/tag-reference.dto.ts (1)
  • ObjectType (8-13)
examples/federation-v2-e2e/todo-service/src/todo-item/user-reference.dto.ts (1)
  • ObjectType (4-9)
examples/federation-v2-e2e/user-service/src/user/user.dto.ts (1)
  • ObjectType (4-21)
🪛 markdownlint-cli2 (0.18.1)
examples/federation-v2-e2e/README.md

16-16: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ 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). (8)
  • GitHub Check: e2e-test (21.x, postgres)
  • GitHub Check: check (23.x, test)
  • GitHub Check: check (22.x, test)
  • GitHub Check: e2e-test (20.x, mysql)
  • GitHub Check: e2e-test (21.x, mysql)
  • GitHub Check: e2e-test (20.x, postgres)
  • GitHub Check: Analyze
  • GitHub Check: federation-e2e-test
🔇 Additional comments (59)
examples/federation-v2-e2e/todo-service/nest-cli.json (1)

1-8: LGTM!

The Nest CLI configuration is correctly formatted and follows standard conventions. The schema reference is valid, schematics collection is appropriate, and compiler options (automatic output directory cleanup) are sensible for development environments.

examples/federation-v2-e2e/user-service/nest-cli.json (1)

1-8: Configuration looks good.

The Nest CLI configuration is standard and properly formatted. The deleteOutDir: true option ensures clean builds, which is appropriate for an example project.

examples/federation-v2-e2e/user-service/tsconfig.json (1)

1-23: Configuration looks good.

This tsconfig.json appropriately enables decorator support (required for NestJS/GraphQL), enforces strict type checking, and targets ES2021. The setup is consistent with NestJS backend service conventions and will support the federation v2 e2e test environment.

examples/federation-v2-e2e/user-service/Dockerfile (1)

1-73: Well-structured multi-stage Dockerfile with good caching strategy.

The build follows Docker best practices: immutable config/deps are copied early to leverage layer caching, source code is added later to avoid cache invalidation on code changes, and the final image is lean.

examples/federation-v2-e2e/todo-service/Dockerfile (2)

4-73: Well-structured multi-stage build with good layer caching strategy.

The Dockerfile correctly leverages multi-stage builds to compile nestjs-query packages in an isolated builder stage and then uses them in the runtime stage. Dependency files are copied before source code, which maximizes Docker layer caching. The use of npm pack to create local tarballs for installation is a solid approach for testing local package versions in an E2E environment.


56-59: Verify package names and versions are correct.

Ensure that the glob patterns for the local package tarballs (ptc-org-nestjs-query-core-*.tgz, etc.) match the actual package names and are available after the builder stage. If package versions are pinned or vary, confirm the patterns will reliably resolve.

examples/federation-v2-e2e/user-service/package.json (1)

1-38: The dependencies are correctly configured for Express 5 and Apollo Server v5 federation; remove the incorrect @parent() decorator claim.

The package.json looks well-configured. However, the original review comment contains a technical misunderstanding:

  • @parent() is not used in @ResolveReference(): The review incorrectly suggests that @nestjs/graphql 13.2.0 includes a @parent() decorator fix for @ResolveReference(). In reality, @ResolveReference receives the reference object directly as a parameter. The @parent() decorator is used in field resolvers (@ResolveField), not in federation reference resolution. This concern should be removed.

  • Express 5 + Apollo v5 compatibility is correct: @as-integrations/[email protected] explicitly supports @apollo/server v5 (added in v1.1.2), so the combination of @as-integrations/express5@^1.1.2 with @apollo/server@^5.2.0 is compatible and properly configured. No issue here.

  • Caret versioning is acceptable: While using ^ for all dependencies could theoretically allow minor version drift, the chosen versions are stable and well-tested. If stricter reproducibility is needed for CI, pinning could be considered as a future optimization, but it's not necessary.

Likely an incorrect or invalid review comment.

examples/federation-v2-e2e/.dockerignore (1)

1-2: Ignoring node_modules and dist in Docker context is appropriate

This will keep build contexts small and avoid copying unnecessary artifacts into images.

examples/federation-v2-e2e/.gitignore (1)

1-1: Un-ignoring package-lock.json here makes sense for reproducible e2e installs

This allows committing a dedicated lockfile for this example even if the root ignores it.

packages/query-graphql/__tests__/integration/federation-n1/fixtures/test-data.ts (1)

8-10: FK-aware deletion order in test data setup looks good

Deleting TodoItem rows before TodoList rows matches the FK relationship and avoids constraint violations during test setup/teardown.

examples/federation-v2-e2e/e2e-test/tsconfig.json (1)

1-15: TS config is reasonable for the Jest/Node e2e setup

Strict mode, ES2022 target, and rootDir: "./e2e" are all sensible for this small test project; nothing concerning here.

examples/federation-v2-e2e/gateway/nest-cli.json (1)

1-8: Gateway Nest CLI configuration is standard

Using sourceRoot: "src" with deleteOutDir: true is the usual minimal setup; nothing problematic here.

examples/federation-v2-e2e/e2e-test/package.json (1)

1-23: > Likely an incorrect or invalid review comment.

examples/federation-v2-e2e/todo-service/package.json (1)

1-38: Dependency versions are compatible and well-aligned.

The pinned versions are mutually compatible: @nestjs/graphql v13.2.0 explicitly supports Apollo Server v5, graphql 16.12.0 satisfies Apollo Server v5's peer requirement (>= 16.11.0), @apollo/subgraph 2.12.1 is compatible with Apollo Server 5 and graphql v16, and @nestjs/typeorm v11.0.0 aligns with NestJS v11. Ensure Node.js v20+ is used in CI/Docker, as required by NestJS v11 and Apollo Server v5.

.github/workflows/test.yml (1)

99-118: LGTM! Well-structured federation e2e test job.

The new CI job appropriately uses Docker Compose to run federation end-to-end tests in isolation. The use of --exit-code-from e2e-test ensures test failures propagate correctly, and the failure log step aids debugging.

examples/federation-v2-e2e/gateway/package.json (1)

1-35: LGTM! Gateway dependencies are well-configured.

The package configuration correctly sets up Apollo Federation V2 gateway with compatible NestJS and GraphQL versions.

examples/federation-v2-e2e/e2e-test/jest.config.js (1)

1-7: LGTM! Jest configuration is appropriate for e2e tests.

The 60-second timeout is suitable for Docker-based federation tests, and the test pattern correctly targets e2e specs.

packages/query-graphql/src/loader/reference.loader.ts (2)

25-30: LGTM! String-based Map keys solve ID type mismatch.

The change to use Map<string, DTO> with String(id) coercion ensures consistent lookups regardless of whether federation sends numeric or string IDs. The explanatory comment clearly documents the rationale for this approach.


33-39: LGTM! Consistent string coercion in lookup path.

The String(arg.id) conversion matches the storage logic, ensuring references are correctly resolved even with ID type mismatches between federation representations and entity IDs.

examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts (3)

47-120: LGTM! Comprehensive reference resolution tests.

The tests thoroughly validate cross-service reference resolution with different ID types (numeric for users, UUID for tags), ensuring the @Parent() decorator fix works correctly across scenarios.


163-187: Excellent validation of issue #410 fix.

This test explicitly verifies that the representation parameter is not undefined after the @Parent() decorator fix. The comment at line 166 clearly documents the regression and how it manifested.


189-217: LGTM! Validates the String(id) Map lookup fix.

This test confirms that ID type mismatches between federation representations and entities are handled correctly through string coercion in reference.loader.ts.

examples/federation-v2-e2e/user-service/src/user/user.dto.ts (1)

4-8: LGTM! Correct federation key configuration.

The @key(fields: "id") directive correctly marks this entity for federation reference resolution. The numeric ID type aligns with the e2e tests validating numeric ID handling.

packages/query-graphql/src/resolvers/reference.resolver.ts (2)

2-2: LGTM! Parent decorator import added for the fix.

The Parent decorator import is necessary for the critical fix on line 37.


36-41: Critical fix: @parent() decorator resolves issue #410.

This fix addresses the root cause where the representation parameter was undefined when other parameter decorators were present. The @Parent() decorator correctly extracts the federation representation from the GraphQL execution context.

The fix is minimal, targeted, and maintains compatibility with existing DataLoader support.

examples/federation-v2-e2e/user-service/src/main.ts (1)

5-12: LGTM! Standard NestJS service bootstrap.

The entrypoint correctly initializes the service on port 3000, consistent with the docker-compose configuration and other federation services.

examples/federation-v2-e2e/e2e-test/Dockerfile (1)

1-12: LGTM!

The Dockerfile follows standard practices for containerized test execution with appropriate Node.js base image, dependency installation, and test command.

examples/federation-v2-e2e/tag-service/nest-cli.json (1)

1-8: LGTM!

Standard NestJS CLI configuration with appropriate schema reference and compiler options.

examples/federation-v2-e2e/gateway/Dockerfile (1)

1-27: LGTM!

The Dockerfile appropriately implements a single-stage build for the gateway service with correct dependency management and port exposure.

examples/federation-v2-e2e/tag-service/tsconfig.json (1)

1-23: LGTM!

The TypeScript configuration appropriately enables strict mode and uses sensible compiler options for a NestJS service.

packages/query-graphql/__tests__/integration/federation-n1/dtos/todo-list.dto.ts (1)

1-1: LGTM!

The addition of the @Directive('@key(fields: "id")') decorator correctly enables Federation entity resolution for TodoListDto, aligning with the PR's objective to test and fix Federation reference resolution.

Also applies to: 8-8

examples/federation-v2-e2e/gateway/src/app.module.ts (1)

1-22: File path and code content do not match the review.

The review references examples/federation-v2-e2e/gateway/src/app.module.ts with service names user-service, todo-service, and tag-service. However, the actual file is located at examples/federation-v2/graphql-gateway/src/app.module.ts and uses localhost hardcoded URLs (ports 3001-3004) with service names todo-items, sub-tasks, tags, and user. The code snippet and gateway configuration in the review do not match the actual implementation.

Likely an incorrect or invalid review comment.

packages/query-graphql/__tests__/integration/federation-n1/dtos/todo-item.dto.ts (1)

1-18: Federation key directive on TodoItemDto looks correct

Adding @Directive('@key(fields: "id")') with the corresponding Directive import is the right way to expose TodoItem as a federated entity keyed by id; this aligns with the federation tests and should work smoothly with _entities resolution.

examples/federation-v2-e2e/user-service/src/app.module.ts (1)

1-29: User service AppModule wiring is consistent and appropriate for E2E

The TypeORM and GraphQL federation configuration mirrors the todo/tag services and is suitable for this dedicated E2E environment (env-based DB config, autoLoadEntities, synchronize, and federation v2 schema output), so this module setup looks good.

examples/federation-v2-e2e/tag-service/src/app.module.ts (1)

1-29: Tag service AppModule configuration is consistent and suitable for E2E

The Postgres and federation GraphQL setup (env-driven DB config, autoLoadEntities, synchronize, federation v2 schema) mirrors the other subgraphs and fits the E2E federation scenario, so this module wiring looks good.

examples/federation-v2-e2e/tag-service/src/tag/tag.module.ts (1)

1-31: TagModule resolver config correctly exercises referenceBy with string IDs

The nestjs-query resolver setup for TagDTO with referenceBy: { key: 'id' }, plus the seeder, is a good way to validate federation reference resolution for UUID/string IDs and directly supports the regression coverage described in the PR.

examples/federation-v2-e2e/user-service/src/user/user.module.ts (1)

1-32: UserModule resolver config correctly models the regression scenario

The nestjs-query resolver configuration for UserDTO with referenceBy: { key: 'id' } (and the accompanying comments) is exactly what’s needed to reproduce and guard against the federation referenceBy regression described in issue #410, so this setup looks appropriate.

examples/federation-v2-e2e/user-service/src/user/user.input.ts (1)

1-19: LGTM! Clean input type definitions for e2e testing.

The input types are well-structured and follow NestJS GraphQL conventions. The separation of required fields in CreateUserInput and optional fields in UpdateUserInput is appropriate.

examples/federation-v2-e2e/tag-service/Dockerfile (1)

1-73: LGTM! Well-structured multi-stage build for e2e testing.

The multi-stage approach correctly builds nestjs-query packages from source and installs them as local dependencies. This allows testing against local changes rather than published packages.

examples/federation-v2-e2e/tag-service/src/tag/tag.entity.ts (1)

1-20: LGTM! UUID primary key for testing string ID types in federation.

The use of @PrimaryGeneratedColumn('uuid') is appropriate for validating that federation works correctly with string-based IDs, complementing the numeric IDs used by UserEntity.

examples/federation-v2-e2e/user-service/src/user/user.entity.ts (1)

1-19: LGTM! Standard entity definition for numeric ID testing.

The entity correctly uses @PrimaryGeneratedColumn() for auto-incrementing numeric IDs, which complements the UUID-based TagEntity for comprehensive ID type coverage in federation testing.

examples/federation-v2-e2e/tag-service/src/tag/tag.dto.ts (1)

1-22: LGTM! Well-structured federation DTO for Tag entity.

The DTO correctly implements Apollo Federation requirements with the @key directive and uses appropriate field decorators. The string-based ID field aligns with the UUID primary key in TagEntity.

examples/federation-v2-e2e/tag-service/src/tag/tag.seeder.ts (1)

7-13: File not found in repository.

The review references examples/federation-v2-e2e/tag-service/src/tag/tag.seeder.ts, but this file does not exist in the repository. The actual directory structure uses examples/federation-v2/tag-graphql/ instead of examples/federation-v2-e2e/tag-service/, and no tag.seeder.ts file exists in the codebase. The concerns raised cannot be verified against a non-existent file.

Likely an incorrect or invalid review comment.

examples/federation-v2-e2e/user-service/src/user/user.seeder.ts (1)

8-12: The file path and code referenced in this review comment do not exist in the repository.

The review references examples/federation-v2-e2e/user-service/src/user/user.seeder.ts with hardcoded IDs (1, 2, 3), but this file does not exist. The actual implementation is in examples/federation-v2/user-graphql/e2e/fixtures.ts and does not use hardcoded IDs:

await userRepo.save([
  { name: 'User 1', email: '[email protected]' },
  { name: 'User 2', email: '[email protected]' },
  { name: 'User 3', email: '[email protected]' }
])

The e2e tests confirm that auto-generated IDs (1, 2, 3) are correctly persisted and queryable, with no sequence conflicts. The current approach—allowing @PrimaryGeneratedColumn() to generate IDs naturally—works correctly and avoids the concerns raised in this review.

Likely an incorrect or invalid review comment.

examples/federation-v2-e2e/tag-service/src/tag/tag.input.ts (1)

1-19: LGTM!

Input types are well-structured with proper nullable annotations. The CreateTagInput correctly enforces required name while allowing optional color, and UpdateTagInput appropriately makes both fields optional for partial updates.

packages/query-graphql/__tests__/integration/federation-n1/federation-reference.spec.ts (4)

30-84: Well-structured test setup and teardown.

The test configuration properly sets up an isolated Federation subgraph with in-memory SQLite. The lifecycle management correctly handles cleanup even if setup fails. The referenceBy: { key: 'id' } configuration directly exercises the fix for Issue #410.


101-129: Excellent core regression test for Issue #410.

This test directly validates the @Parent() decorator fix. The comments clearly explain the before/after behavior, and the assertions verify that representations are correctly resolved. This prevents future regressions.


258-280: Good test for string-to-number ID coercion.

This test validates the secondary fix (using String(id) for consistent Map key handling). It ensures Federation works regardless of whether the gateway sends IDs as numbers or strings.


326-329: No action required. The assertion is correct: the error message thrown by the reference resolver (Unable to resolve reference, missing required key ${key} for ${baseName}) contains the substring 'missing required key', and the .toContain() assertion will match it properly.

examples/federation-v2-e2e/todo-service/src/todo-item/tag-reference.dto.ts (1)

1-13: Tag reference DTO is correctly shaped for federation usage.

Object type name, key directive, and UUID/string id field all line up with the Tag subgraph; this is a clean minimal reference DTO for the todo-service side.

examples/federation-v2-e2e/todo-service/src/main.ts (1)

1-12: Bootstrap entrypoint is straightforward and appropriate for the e2e service.

Nest app creation, port binding, and startup logging are minimal and sufficient for this example.

examples/federation-v2-e2e/todo-service/src/app.module.ts (1)

1-29: AppModule configuration looks correct for a federation v2 test subgraph.

TypeORM and GraphQL federation wiring matches the intended todo-service role in the e2e setup, and TodoItemModule is properly imported.

examples/federation-v2-e2e/todo-service/tsconfig.json (1)

1-23: TypeScript configuration is consistent and suitable for the NestJS service.

Decorator support, output paths, and strictness options are all appropriate for this e2e module.

examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.module.ts (1)

1-30: TodoItemModule wiring correctly mirrors the user/tag modules for federation tests.

TypeORM, NestJS Query, resolver config (including referenceBy: { key: 'id' }), and seeder wiring all look consistent and appropriate for exercising the federation reference path.

examples/federation-v2-e2e/todo-service/src/todo-item/user-reference.dto.ts (1)

1-9: User reference DTO cleanly models the federated User key.

The type name, key directive, and numeric ID field align with the user-service UserDTO, so this will work well as a reference from TodoItem.

examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.entity.ts (1)

1-29: TodoItemEntity maps cleanly to the intended schema and test data.

Column definitions and types (including tagId as UUID string) match the DTO and seeder expectations for federation tests.

examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.seeder.ts (1)

1-63: Seeder service follows the same robust pattern as user/tag seeders.

On module init seeding, id/assigneeId/tagId values, and logging behavior provide predictable data for federation e2e tests without impacting non-empty databases.

examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.input.ts (1)

1-31: LGTM!

The input DTOs follow the established patterns from the user-service. The use of defaultValue: false for completed is appropriate, and the nullable annotations are consistent between the TypeScript types and GraphQL decorators.

examples/federation-v2-e2e/todo-service/src/todo-item/todo-item.dto.ts (1)

7-38: Well-structured Federation DTO with good test coverage for ID types.

The DTO correctly demonstrates both numeric (assigneeIdUser) and string/UUID (tagIdTag) reference types, which is valuable for validating the federation fix across different ID representations. The @Reference mappings and field types are consistent with their corresponding reference DTOs.

@Diluka
Copy link
Contributor Author

Diluka commented Dec 5, 2025

@TriPSs This restoration process

  1. Reproduce the issue by setting up a real environment using Docker.
  2. Fix the issue.
  3. Add Docker tests to CI.
  4. Through the above steps, reinvestigate why previous tests were missed.
  5. Add new integration tests, create realistic subgraphs, simulate gateway requests, and verify that they can cover the previously missed test boundaries.

- Fix prettier and eslint errors in federation-v2-e2e files
- Add testPathIgnorePatterns to exclude federation-v2-e2e from main e2e tests
  (it uses Docker and has its own Jest config)
@TriPSs
Copy link
Owner

TriPSs commented Dec 5, 2025

Can you fix the lint/test issues?

@Diluka
Copy link
Contributor Author

Diluka commented Dec 5, 2025

Can you fix the lint/test issues?

I've checked, it's not a problem I introduced, it's a formatting issue with the previous code.

examples:lint logs
diluka@diluka-mini:~/sources/repo/nestjs-query$ cd /home/diluka/sources/repo/nestjs-query && npx nx run examples:lint

> nx run examples:lint


Linting "examples"...
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.7.3

Please only submit bug reports when using the officially supported version.

=============

/home/diluka/sources/repo/nestjs-query/examples/mongoose/e2e/todo-item.resolver.spec.ts
    60:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
    61:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
    88:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   106:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   136:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   162:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   192:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   219:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   220:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   285:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   336:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   401:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   402:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   447:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   494:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   495:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   512:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   537:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   572:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   598:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   599:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   621:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   653:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   690:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   716:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   717:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   741:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   775:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   813:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   839:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   840:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   863:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   893:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   928:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   953:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   980:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   981:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1002:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1028:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1072:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1097:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1122:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1123:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1143:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1170:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1194:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1195:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1215:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1240:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1263:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1287:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1288:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1328:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1329:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1369:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1370:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1409:3  warning  Some tests seem to be commented  jest/no-commented-out-tests

✖ 57 problems (0 errors, 57 warnings)

✖ 57 problems (0 errors, 57 warnings)


————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target lint for project examples (21s)


 NX   Nx Cloud encountered some problems

Request failed with status code 400. (code: 400)

Comment on lines 8 to 10
// Clear existing data (must delete items first due to foreign key)
await dataSource.getRepository(TodoItem).delete({})
await dataSource.getRepository(TodoList).delete({})
Copy link
Owner

Choose a reason for hiding this comment

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

This is causing the tests to fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, deleteAll() reported that the method didn't exist when I ran it locally. Now, it works perfectly locally. So what are the lint rules? Why isn't it working?

Copy link
Owner

Choose a reason for hiding this comment

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

Probably outdated deps? TypeORM was updated recently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

局部截取_20251205_160714 局部截取_20251205_160740 That's outrageous!

@TriPSs
Copy link
Owner

TriPSs commented Dec 5, 2025

Can you fix the lint/test issues?

I've checked, it's not a problem I introduced, it's a formatting issue with the previous code.

examples:lint logs

Those are warnings, the errors:

 /home/runner/work/nestjs-query/nestjs-query/examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts
      5:16  error  Unsafe construction of an any type value    @typescript-eslint/no-unsafe-call
     63:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
     82:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
     83:32  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    108:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    109:27  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    132:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    136:21  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    150:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    154:27  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    179:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    182:33  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    183:28  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    204:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call

Added a comment why the tests are failng

@Diluka
Copy link
Contributor Author

Diluka commented Dec 5, 2025

Can you fix the lint/test issues?

I've checked, it's not a problem I introduced, it's a formatting issue with the previous code.
examples:lint logs

Those are warnings, the errors:

 /home/runner/work/nestjs-query/nestjs-query/examples/federation-v2-e2e/e2e-test/e2e/federation.spec.ts
      5:16  error  Unsafe construction of an any type value    @typescript-eslint/no-unsafe-call
     63:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
     82:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
     83:32  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    108:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    109:27  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    132:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    136:21  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    150:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    154:27  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    179:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    182:33  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    183:28  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call
    204:30  error  Unsafe call of an `error` type typed value  @typescript-eslint/no-unsafe-call

Added a comment why the tests are failng

I've run lint locally and it shows no problems in my IDE. Could it be that this is a separate project with its own dependencies, and shouldn't be checked by lint?


graphql-request This package is not installed in external projects; it is the validation toolkit for this example project.

@TriPSs
Copy link
Owner

TriPSs commented Dec 5, 2025

You are running nx lint examples in this case?

@Diluka
Copy link
Contributor Author

Diluka commented Dec 5, 2025

You are running nx lint examples in this case?

lint examples
diluka@diluka-mini:~/sources/repo/nestjs-query$ cd /home/diluka/sources/repo/nestjs-query && npx nx lint examples 2>&1

> nx run examples:lint  [existing outputs match the cache, left as is]


Linting "examples"...
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.7.3

Please only submit bug reports when using the officially supported version.

=============

/home/diluka/sources/repo/nestjs-query/examples/mongoose/e2e/todo-item.resolver.spec.ts
    60:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
    61:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
    88:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   106:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   136:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   162:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   192:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   219:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   220:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   285:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   336:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   401:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   402:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   447:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   494:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   495:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   512:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   537:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   572:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   598:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   599:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   621:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   653:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   690:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   716:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   717:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   741:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   775:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   813:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   839:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   840:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   863:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   893:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   928:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   953:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   980:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
   981:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1002:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1028:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1072:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1097:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1122:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1123:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1143:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1170:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1194:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1195:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1215:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1240:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1263:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1287:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1288:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1328:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1329:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1369:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1370:3  warning  Some tests seem to be commented  jest/no-commented-out-tests
  1409:3  warning  Some tests seem to be commented  jest/no-commented-out-tests

✖ 57 problems (0 errors, 57 warnings)

✖ 57 problems (0 errors, 57 warnings)


————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target lint for project examples (144ms)

Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

View logs and run details at https://nx.app/runs/JpmkYYlIdJ

@Diluka
Copy link
Contributor Author

Diluka commented Dec 5, 2025

I understand. I've already run npm install in my local test, so the dependencies exist. CI doesn't execute the installation command for this example, so it doesn't have the dependencies, hence the lint error. Should I exclude it from lint checks, or install all the packages it uses from the main project's dev dependencies?

@TriPSs
Copy link
Owner

TriPSs commented Dec 5, 2025

I understand. I've already run npm install in my local test, so the dependencies exist. CI doesn't execute the installation command for this example, so it doesn't have the dependencies, hence the lint error. Should I exclude it from lint checks, or install all the packages it uses from the main project's dev dependencies?

Not sure that I follow? The CI does install deps. Can you push the fixes for the testing, I will checkout the linting.

@TriPSs TriPSs merged commit c1583d0 into TriPSs:master Dec 5, 2025
15 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.

Federation referenceBy broken since v9.2.0: representation parameter undefined

2 participants