Full-stack Developer interview question
How do you keep frontend and backend contracts aligned?
Keep contracts aligned with one versioned schema such as OpenAPI, generate or validate clients where useful, add consumer and provider contract tests, and deploy backward-compatible changes before removing old fields.
Direct answer
What a strong answer covers
How it works
The contract is a single artefact, usually an OpenAPI or GraphQL schema, owned by the backend and versioned in the repository, from which the frontend generates its client types so a field rename fails compilation rather than a user session. Consumer-driven contract tests record what each frontend actually uses and run against the provider in CI, so the backend cannot remove or change those fields without a failing build. Changes ship in an expand-then-contract order: add the new field, migrate consumers, then remove the old one after usage drops to zero.
Example
The web app generates TypeScript types from openapi.json on every build; when the backend renamed customer_name to customerName, the frontend build failed immediately instead of showing empty names in production. A Pact test for the mobile app asserts that GET /orders returns status and total, so a backend PR that drops total fails the provider verification job.
Common mistakes
- Hand-writing frontend types that drift from the real responses.
- Deploying a breaking backend change and the frontend change at the same moment and depending on both succeeding.
- Treating the mock server as the contract and never verifying it against the real provider.
A useful answer structure
Answer from your own work.
Do not memorise a script: use only examples you can explain honestly in follow-up questions.
Open the desktop workspace and rehearse a clear answer in your own words.