In code-first, you write TypeScript classes decorated with @ObjectType() and @Field() and NestJS generates the SDL schema automatically. In schema-first, you write the .graphql SDL file by hand and NestJS generates TypeScript interfaces from it. Code-first keeps TypeScript as the single source of truth; schema-first treats the SDL as the API contract.
Code-first — single source of truth in TypeScript; full IDE support; decorators keep schema and types in sync.
Schema-first — SDL is the team contract; great when frontend and backend agree on the schema upfront.
Code-first risk: decorators can feel verbose for large schemas with many types.
Schema-first risk: interface drift — the SDL and generated TypeScript can silently diverge if code generation is skipped.
Most NestJS teams default to code-first because it avoids the separate SDL-maintenance step.