Application
Application composes a Module with its HTTP/GraphQL surface and runs it.
Lifecycle:
new Application(options)— cheap, no side effects.await service.init()— runsmodule.init()then builds the GraphQL and Fastify instances. Idempotent.await service.start()— runsonStart, binds the port and installs signal handlers. A signal-driven shutdown runsstop(), thenonShutdown.
Tests can use service.fastify.inject(...) after init() without calling
start(). Use createApplication for the common one-liner that
does steps 1 and 2 together.
The GraphQL user-context type lives on ApplicationOptions<TUserContext>
(where it couples graphql.context to graphql.plugins), not on the
service itself — the service exposes nothing typed by it.
import { Application } from "@evolve-framework/core";new Application(options: ApplicationOptions<any>)| Option | Type | Description |
|---|---|---|
name | string | The name of the domain service, used for identification and logging. |
module | Module<any> | The module that encapsulates the domain's business logic, GraphQL schema, and resolvers. This is a required property as the domain service relies on the module to define its functionality. |
http | HTTPServerOptions | HTTP server configuration. Required to start the HTTP server that handles both GraphQL and REST requests. |
onStart? | (() => void | Promise<void>) | Sets up what the modules share, such as the cache connection, when
|
onShutdown? | (() => void | Promise<void>) | Releases what a finished |
graphql? | GraphQLOptions<any> | Optional GraphQL server configuration. This is only used if the module provides a GraphQL configuration. If the module does not provide a GraphQL configuration, this property is ignored. |
| Method | Description |
|---|---|
init(): Promise<void> | Runs module.init(), then builds the GraphQL and Fastify servers from the module and the options. |
start(): Promise<void> | Runs onStart, binds the HTTP server to http.address and installs signal handlers that run stop() and then onShutdown. |
stop(): Promise<void> | Closes HTTP (draining open requests), disposes GraphQL, then closes the module. |
getYogaInstance(): GraphQLInstance<ServerContext, any> | undefined | The GraphQL server, or undefined before init() or when the module serves no GraphQL. |

