Skip to content

adrian/api-routes-2026-04-02#5066

Open
adrians5j wants to merge 4 commits intonextfrom
adrian/api-routes-2026-04-02
Open

adrian/api-routes-2026-04-02#5066
adrians5j wants to merge 4 commits intonextfrom
adrian/api-routes-2026-04-02

Conversation

@adrians5j
Copy link
Copy Markdown
Member

@adrians5j adrians5j commented Apr 2, 2026

What changed

Users can now register custom REST routes on the API Gateway and GraphQL Lambda directly from webiny.config.tsx using <Api.Route>. A route handler is defined as a class implementing Route.Interface, with full support for dependency injection (e.g. Logger, BuildParams).

Why

Previously there was no first-class way to add custom REST endpoints to the API app. Users had to manually wire up Pulumi route registration and Fastify route plugins. This extension covers both concerns automatically.

How

Api.Route is a new extension in @webiny/project-aws (ApiRoute.tsx). Its build() step modifies apps/api/graphql/src/extensions.ts to inject a createContextPlugin (registering the handler class in the DI container) and a createRoute call (registering the Fastify route with the hardcoded path/method from the extension props). Its render() emits an <ApiPulumi> that runs RegisterRoutesPulumi at deploy time, calling graphql.addRoute() on the ApiGraphql Pulumi module to register the route on API Gateway.

The Route abstraction lives in @webiny/handler and is exported to webiny/api/route via the auto-generated webiny package.

Changelog

Introduced the Api.Route Extension

A new Api.Route extension is now available in webiny.config.tsx, allowing developers to register custom REST routes on the API Gateway and GraphQL Lambda. Route handlers are plain classes with dependency injection support, and both the cloud infrastructure (API Gateway route) and the runtime routing (Fastify handler) are configured automatically.

@adrians5j adrians5j added this to the 6.2.0 milestone Apr 2, 2026
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.

1 participant