Skip to content

Conversation

@notaphplover
Copy link
Member

@notaphplover notaphplover commented Dec 28, 2025

Changed

  • Updated tests to cover fastify integration use case.

Summary by CodeRabbit

  • New Features

    • Extended server framework support to include Fastify alongside Express.
  • Tests

    • Added comprehensive test coverage for the new framework option, including GraphQL queries and WebSocket subscriptions, mirroring existing Express scenarios.

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

update tests to cover fastify integration use case
@notaphplover notaphplover self-assigned this Dec 28, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 28, 2025

⚠️ No Changeset found

Latest commit: 5762ea4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Adds Fastify support to the apollo-subscription-ws package by introducing Fastify-related devDependencies and extending integration tests to exercise a Fastify-based Apollo server (HTTP queries + WebSocket subscriptions), while preserving existing Express tests and public API surface.

Changes

Cohort / File(s) Summary
Fastify Framework Integration
packages/apollo-subscription-ws/package.json
Added devDependencies: @as-integrations/fastify, @inversifyjs/apollo-fastify, @inversifyjs/http-fastify, and fastify. No runtime dependency or public API changes.
Test Coverage Extension
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
Added Fastify-based integration tests mirroring existing Express tests: builds Fastify instance, wires schema/resolvers, runs HTTP GraphQL query and WebSocket subscription, includes lifecycle setup/teardown and assertions.

Sequence Diagram(s)

(Skipped — changes are limited to test additions and devDependency updates; no new multi-component runtime control-flow requiring visualization.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I hopped into tests with a joyful cheer,

Fastify and WebSockets now gather near,
Queries and subs in a nimble parade,
Express waved hello as new hops were made,
A rabbit's small dance for each passing build 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main change: updating tests for ApolloSubscriptionServerContainerModule to cover Fastify integration alongside existing Express tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/update-subscription-tests-to-cover-fastify-integration

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

@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 (1)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts (1)

232-439: Consider extracting common test utilities to reduce duplication.

The Fastify test suite duplicates the GraphQL schema, resolvers, and test assertion logic from the Express suite. While some duplication is acceptable in integration tests for clarity, you could extract common elements like:

  • GraphQL schema and resolver definitions into shared constants
  • WebSocket connection/subscription test utilities
  • Common assertion helpers

This would improve maintainability if the test logic needs to be updated in the future.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 195c690 and 735d110.

📒 Files selected for processing (2)
  • packages/apollo-subscription-ws/package.json
  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier with shared configuration from @inversifyjs/foundation-prettier-config

Files:

  • packages/apollo-subscription-ws/package.json
  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

**/package.json: Use workspace protocol (workspace:*) for internal dependencies in package.json
Pin development dependencies to specific versions for security and reproducibility

Files:

  • packages/apollo-subscription-ws/package.json
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use strict mode enabled for TypeScript across all packages

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{spec,int.spec,spec-d}.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{spec,int.spec,spec-d}.ts: Use Vitest for unit and integration testing with extensive test coverage
Mock external modules using vitest.fn() and vitest.mock() in tests

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name unit tests with *.spec.ts file extension

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.int.spec.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name integration tests with *.int.spec.ts file extension

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{spec,int.spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{spec,int.spec}.ts: Organize test describe blocks in four-layer structure: Class → Method → Input → Flow scopes
Use descriptive test names with 'when called, and [condition]' pattern

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint with shared configuration from @inversifyjs/foundation-eslint-config

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🧠 Learnings (3)
📚 Learning: 2025-12-24T10:31:07.649Z
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/*.{spec,int.spec,spec-d}.ts : Use Vitest for unit and integration testing with extensive test coverage

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
📚 Learning: 2025-12-24T10:31:07.649Z
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/*.{spec,int.spec,spec-d}.ts : Mock external modules using vitest.fn() and vitest.mock() in tests

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
📚 Learning: 2025-12-27T21:04:29.742Z
Learnt from: notaphplover
Repo: inversify/graphql PR: 32
File: packages/apollo-fastify/src/apollo/controllers/buildApolloServerFastifyController.int.spec.ts:19-112
Timestamp: 2025-12-27T21:04:29.742Z
Learning: The 4-layer describe block structure (Class → Method → Input → Flow scopes) applies only to unit tests. Use this 4-layer structure for tests in files matching '**/*.spec.ts'. Do not apply to integration tests in files like '**/*.int.spec.ts'.

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🔇 Additional comments (3)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts (2)

7-7: LGTM! Fastify imports are properly structured.

The new imports follow the same pattern as the existing Express imports and provide the necessary types and modules for Fastify integration.

Also applies to: 11-11, 13-14


22-22: Good clarification for test organization.

Renaming the describe block to explicitly mention Express improves test readability and distinguishes it from the new Fastify test suite.

packages/apollo-subscription-ws/package.json (1)

13-13: Use workspace protocol for internal @inversifyjs packages instead of pinned versions.

@inversifyjs/http-fastify and @inversifyjs/http-express should use "workspace:" to match the coding guideline "Use workspace protocol (workspace:) for internal dependencies in package.json". They are currently pinned to "4.9.1", inconsistent with @inversifyjs/apollo-fastify which correctly uses "workspace:*". External dependencies (@as-integrations/fastify, fastify) are correctly pinned to latest versions (3.1.0, 5.6.2).

⛔ Skipped due to learnings
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/package.json : Use workspace protocol (workspace:*) for internal dependencies in package.json
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/package.json : Pin development dependencies to specific versions for security and reproducibility

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: 0

🧹 Nitpick comments (1)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts (1)

238-263: Consider extracting shared test fixtures and logic.

The Fastify test suite duplicates ~200 lines from the Express suite (schema definition, resolvers, HTTP request test setup, and WebSocket subscription test logic). While integration tests often maintain independence for clarity, this level of duplication creates maintenance overhead—any changes to test logic or fixtures must be applied twice.

Consider extracting:

  • Common GraphQL schema and resolvers into shared constants
  • WebSocket subscription test flow into a reusable helper function parameterized by server type

This would maintain test independence while reducing duplication and improving maintainability.

Example refactoring approach
// Shared test fixtures
const TEST_GRAPHQL_SCHEMA: TypeSource = `
type RootQuery {
  hello: String!
}
schema {
  query: RootQuery
  subscription: RootSubscription
}
type RootSubscription {
  subscribeHello: RootQuery!
}
`;

const TEST_GRAPHQL_RESOLVERS: IResolvers = {
  RootQuery: { hello: () => 'world' },
  RootSubscription: {
    subscribeHello: {
      subscribe: async function* () {
        yield { subscribeHello: { hello: 'world' } };
        yield { subscribeHello: { hello: 'world' } };
      },
    },
  },
};

// Shared test helper
async function testWebSocketSubscription(port: number): Promise<unknown[]> {
  const subscriptionResults: unknown[] = [];
  const wsClient = new WebSocket(
    `ws://localhost:${port}/subscriptions`,
    'graphql-transport-ws',
  );
  // ... rest of subscription test logic
  return subscriptionResults;
}

Then reference these in both Express and Fastify test suites.

Also applies to: 314-329, 344-410

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 735d110 and 5762ea4.

📒 Files selected for processing (1)
  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use strict mode enabled for TypeScript across all packages

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{spec,int.spec,spec-d}.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{spec,int.spec,spec-d}.ts: Use Vitest for unit and integration testing with extensive test coverage
Mock external modules using vitest.fn() and vitest.mock() in tests

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name unit tests with *.spec.ts file extension

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.int.spec.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name integration tests with *.int.spec.ts file extension

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{spec,int.spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{spec,int.spec}.ts: Organize test describe blocks in four-layer structure: Class → Method → Input → Flow scopes
Use descriptive test names with 'when called, and [condition]' pattern

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier with shared configuration from @inversifyjs/foundation-prettier-config

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint with shared configuration from @inversifyjs/foundation-eslint-config

Files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🧠 Learnings (3)
📚 Learning: 2025-12-24T10:31:07.649Z
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/*.{spec,int.spec,spec-d}.ts : Mock external modules using vitest.fn() and vitest.mock() in tests

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
📚 Learning: 2025-12-24T10:31:07.649Z
Learnt from: CR
Repo: inversify/graphql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-24T10:31:07.649Z
Learning: Applies to **/*.{spec,int.spec,spec-d}.ts : Use Vitest for unit and integration testing with extensive test coverage

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
📚 Learning: 2025-12-27T21:04:29.742Z
Learnt from: notaphplover
Repo: inversify/graphql PR: 32
File: packages/apollo-fastify/src/apollo/controllers/buildApolloServerFastifyController.int.spec.ts:19-112
Timestamp: 2025-12-27T21:04:29.742Z
Learning: The 4-layer describe block structure (Class → Method → Input → Flow scopes) applies only to unit tests. Use this 4-layer structure for tests in files matching '**/*.spec.ts'. Do not apply to integration tests in files like '**/*.int.spec.ts'.

Applied to files:

  • packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts
🧬 Code graph analysis (1)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts (3)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.ts (1)
  • ApolloSubscriptionServerContainerModule (17-62)
packages/apollo-fastify/src/apollo/modules/ApolloFastifyServerContainerModule.ts (1)
  • ApolloFastifyServerContainerModule (22-68)
packages/apollo-subscription-ws/src/apollo/models/wsServerServiceIdentifier.ts (1)
  • wsServerServiceIdentifier (4-5)
🔇 Additional comments (3)
packages/apollo-subscription-ws/src/apollo/modules/ApolloSubscriptionServerContainerModule.int.spec.ts (3)

7-14: LGTM! Fastify imports are correctly added.

The new imports for Fastify integration (context argument, server module, HTTP adapter, and instance type) are all properly used in the new test suite.


22-22: LGTM! Improved test suite description.

Explicitly mentioning Express in the describe block improves clarity and distinguishes it from the new Fastify integration tests.


232-304: LGTM! Fastify integration is correctly implemented.

The Fastify test suite setup properly:

  • Uses Fastify-specific modules (ApolloFastifyServerContainerModule, InversifyFastifyHttpAdapter)
  • Starts the server using the Promise-based listen() API at line 298 (past review comment has been addressed ✓)
  • Extracts the port from fastifyInstance.server.address() for test assertions
  • Configures WebSocket subscriptions via the shared ApolloSubscriptionServerContainerModule

The server listens on a random port (default for listen() without arguments), which is appropriate for integration tests to avoid port conflicts.

@notaphplover notaphplover merged commit 7c07982 into master Dec 28, 2025
4 checks passed
@notaphplover notaphplover deleted the test/update-subscription-tests-to-cover-fastify-integration branch December 28, 2025 17:08
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