feat(frameworks): add NestJS support (#220) (#225)

Detect NestJS projects and emit `route` nodes (each linked by a `references`
edge to its handler method) across all four transport layers:

- HTTP controllers: @Controller prefix joined with
  @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@All
- GraphQL resolvers: @Query/@Mutation/@Subscription
- Microservices: @MessagePattern/@EventPattern
- WebSocket gateways: @SubscribeMessage (prefixed with gateway namespace)

Detected from any @nestjs/* dependency in package.json (falls back to scanning
*.controller.ts/*.resolver.ts/*.gateway.ts). Handles class+method path joining
with empty @Controller()/@Get(), a string-aware balanced-paren arg reader so
GraphQL type thunks (@Query(() => [User])) aren't truncated, stacked decorators
(@UseGuards) when locating the handler, and disambiguates the @Query() GraphQL
method decorator from the REST @Query() param decorator (GraphQL only counts
inside @Resolver classes). Also resolves injected *Service/*Controller refs to
their classes by Nest file-naming convention.

Adds 18 framework tests; updates the README framework table and CHANGELOG.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-05-20 17:09:54 -05:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 5c6e5d5c67
commit 948b287536
5 changed files with 751 additions and 0 deletions
+11
View File
@@ -10,6 +10,17 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- **Framework routes (NestJS)**: CodeGraph now recognises NestJS projects and
emits `route` nodes — each linked by a `references` edge to its handler
method — across all four transport layers: HTTP controllers (the
`@Controller` prefix joined with `@Get`/`@Post`/`@Put`/`@Patch`/`@Delete`/
`@Head`/`@Options`/`@All`, including empty `@Controller()`/`@Get()`),
GraphQL resolvers (`@Query`/`@Mutation`/`@Subscription`), microservice
handlers (`@MessagePattern`/`@EventPattern`), and WebSocket gateways
(`@SubscribeMessage`, prefixed with the gateway namespace). Detected
automatically from any `@nestjs/*` dependency in `package.json`. Querying a
controller method or resolver now surfaces the route that binds it.
Resolves [#220](https://github.com/colbymchenry/codegraph/issues/220).
- **MCP / explore**: `codegraph_explore` source sections now carry line
numbers (cat -n style `<num>\t<code>`, matching the Read tool). This lets
the agent cite `file:line` straight from the explore payload instead of