Questions
17 of 25
1How do you bootstrap a NestJS GraphQL application in code-first mode?
2How do you define a GraphQL object type, enum, and union in code-first NestJS?
3How does NestJS schema-first approach differ in setup and when would you choose it over code-first?
4How do you implement a subscription using PubSub in NestJS GraphQL?
5What is the N+1 problem in GraphQL and how does DataLoader solve it?
6How do you make a DataLoader available in the GraphQL context so every resolver can access it in NestJS?
7How do you handle DataLoader cache invalidation and avoid serving stale data in NestJS?
8How do you pass arguments to a GraphQL query and validate them using @Args and input types in NestJS?
9How do you define a GraphQL mutation in NestJS and what input type conventions should you follow?
10What is the difference between @ObjectType() and @InputType() in NestJS GraphQL and why can't you reuse the same class for both?
11How do you add authorization guards to GraphQL resolvers in NestJS?
12How do you implement query complexity analysis to prevent expensive GraphQL queries in NestJS?
13How do you test a NestJS GraphQL resolver with TestingModule?
14How do you implement and use a custom GraphQL scalar type in NestJS?
15How do you handle GraphQL errors and return partial results for mutations in NestJS?
16How do you filter subscription events so each client only receives events relevant to them in NestJS?
17How do you implement schema stitching or federation for a micro-frontend GraphQL architecture in NestJS?
18What is the difference between code-first and schema-first approaches in NestJS GraphQL?
19What is a resolver in NestJS GraphQL and how do you define a root query resolver?
20What are field resolvers in NestJS GraphQL and when do you use them instead of fetching all data in the root query?
21How do you access the GraphQL context including the authenticated user inside a resolver in NestJS?
22What is a GraphQL subscription and how do you enable it in NestJS?
23How do you scale GraphQL subscriptions across multiple NestJS instances?
24How do you implement a DataLoader in NestJS and scope it correctly per request?
25How do you implement cursor-based pagination in NestJS GraphQL using the Relay Connection spec?
17 / 25

How do you implement schema stitching or federation for a micro-frontend GraphQL architecture in NestJS?

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.

Apollo Federation subgraph and gateway setup
Apollo Federation key concepts:
  1. 1

    @key(fields: 'id') — marks an entity that can be referenced and resolved across subgraphs.

  2. 2

    @ResolveReference() — the method the gateway calls when it needs to resolve an entity by its key.

  3. 3

    @extends and @external — used in subgraphs that extend an entity defined in another subgraph.

  4. 4

    IntrospectAndCompose — gateway introspects running subgraph schemas and composes a unified supergraph.

  5. 5

    Each service is independently deployable — the gateway handles schema composition at query time.