All jobs / Backend developer / API Development
Backend developer interview question · 0–1 years
In a GraphQL API, what is the schema and what is a resolver?
The strongest answer
The schema is the typed contract — the types and fields a client may ask for — and a resolver is the function that produces the value for one of those fields when a query asks for it
Why it works
Right — one contract, one function per field. That per-field model is also why field-level fetching needs care.
What a good answer covers
- The schema is the contract.
- Types and fields clients may request.
- A resolver returns one field.
- Resolvers are code, not the database.
Answers that fall short
- Close, but not the strongest: The schema describes the data and the resolvers fetch it from the database
Close, but a resolver is per field rather than per query, and it can read from anything: another service, a cache, memory. - Weak: The schema is documentation generated from the resolvers, so the resolvers are the real contract
It is the other way round. The schema is the contract clients build against, and resolvers must satisfy it. - Red flag: GraphQL replaces the API layer: the client queries the database directly through the schema
Nothing is exposed directly; resolvers are server code with the same authorisation duties as any endpoint.
Who gets asked this
More API Development questions
- The interviewer asks: “Do you return the database entity as JSON?” Strongest answer?
- The interviewer asks: “A handler throws. What does the client see?” Strongest answer?
- The interviewer asks: “How do you paginate a list endpoint?” Strongest answer?
- The interviewer asks: “Where do you validate input?” Strongest answer?
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?
- When would you pick gRPC over a JSON REST API, and what do you give up?