Use Apollo Federation where each NestJS service declares its own subgraph schema. Mark federated entities with @Directive('@key') and implement @ResolveReference() so the gateway can fetch them by ID. The gateway uses ApolloGatewayDriver with IntrospectAndCompose to stitch all subgraph schemas into a unified supergraph.
@key(fields: 'id') — marks an entity that can be referenced and resolved across subgraphs.
@ResolveReference() — the method the gateway calls when it needs to resolve an entity by its key.
@extends and @external — used in subgraphs that extend an entity defined in another subgraph.
IntrospectAndCompose — gateway introspects running subgraph schemas and composes a unified supergraph.
Each service is independently deployable — the gateway handles schema composition at query time.