Fix Apollo Server 5 Express integration and harden finance cluster service - #14
Merged
charles2ke merged 4 commits intoSep 3, 2026
Conversation
…it tests Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement unified GraphQL API for finance cluster integration
Fix Apollo Server 5 Express integration and harden finance cluster service
Sep 3, 2026
charles2ke
approved these changes
Sep 3, 2026
There was a problem hiding this comment.
🟡 Changes recommended
The newly added @as-integrations/express4@1.1.2 requires Node >=20 (per lockfile) while the repo still advertises Node >=18 in package.json/README, creating an install/runtime support mismatch that should be resolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes the service startup break caused by Apollo Server 5 removing the @apollo/server/express4 export, and strengthens the finance cluster service by adding in-flight request de-duplication plus targeted unit tests and documentation updates.
Changes:
- Switch Express integration to
expressMiddlewarefrom@as-integrations/express4sonpm startworks with Apollo Server 5. - Add an in-flight promise map to the finance TTL cache to dedupe concurrent upstream reads and stamp expiry on resolution.
- Add finance unit tests (normalization, aggregation, tax estimation, config, and batching) and update README to document the stack and caching behavior.
File summaries
| File | Description |
|---|---|
| src/index.js | Updates Apollo/Express middleware import path for Apollo Server 5 compatibility. |
| src/services/financeService.js | Adds in-flight de-duplication around the existing TTL cache to reduce duplicate upstream calls. |
| test/finance.test.js | Introduces unit tests covering finance domain normalization, aggregation, config, and caching/batching behavior. |
| README.md | Updates the stack description and documents caching/de-duplication in the finance data-flow. |
| package.json | Adds @as-integrations/express4 dependency required for Apollo Server 5 + Express 4 integration. |
| package-lock.json | Locks the new dependency and its metadata (including Node engine requirement). |
Review details
- Files reviewed: 5/6 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
charles2ke
approved these changes
Sep 3, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The finance cluster integration (OpenTrading / Portfolio-Watcher / tax-break behind a unified GraphQL API) already exists on
main, but the service could not actually start:@apollo/serveris pinned to^5.5.1and Apollo Server 5 removed the@apollo/server/express4subpath, sonpm startdied at import time.Changes
src/index.js): importexpressMiddlewarefrom@as-integrations/express4(peer range@apollo/server ^4 || ^5,express ^4) instead of the removed built-in subpath. No API or context wiring changes.src/services/financeService.js): the TTL cache now tracks in-flight promises, so concurrent resolvers hitting the same upstream key (trading,portfolio) share one connector call rather than fanning out duplicates. Cache expiry is stamped on resolution rather than on request start.test/finance.test.js): unit coverage for the layers previously only exercised end-to-end — field normalization across inconsistent upstream shapes,tradeToTaxEvent(sell vs. buy), portfolio aggregation totals, trade filtering, year-scoped tax estimation, env-driven config defaults/overrides, and the new in-flight dedup.@as-integrations/express4; data-flow section documents the caching/de-duplication step.Notes for reviewers
@as-integrations/express5— is a larger change and was left out.