Backend
GraphQL interview questions on schema definition, queries, mutations, resolvers, and comparison with REST for API design.
Commonly asked at: Commonly asked at API-heavy product companies such as Meesho, Urban Company, and Swiggy — general pattern, not company-verified.
Company names below are mentioned only to indicate the general type/level of interview these questions are common at, based on widely known industry patterns. This content is not affiliated with, endorsed by, or sourced from any confidential material of the named companies. All trademarks belong to their respective owners.
What is GraphQL, and how is it different from REST?
Tip: Say "client specifies exact fields" — that's the one-line core difference to lead with.
GraphQL is a query language for APIs that lets clients request exactly the data they need in one request, instead of hitting multiple fixed REST endpoints. REST often over- or under-fetches data since each endpoint returns a fixed shape, while GraphQL lets the client control exactly what comes back.
What are the three main GraphQL operation types?
Tip: Just name and define each briefly — this is a quick recall question.
Query for reading data, Mutation for creating/updating/deleting data, and Subscription for real-time updates over a persistent connection like WebSockets.
What is a GraphQL schema, and why does it matter?
Tip: Call it a "contract between client and server" — that phrase is the expected framing.
A schema defines the API's structure — what types exist and what fields/queries/mutations are available. It's a strongly-typed contract between client and server, and tools can use it to auto-generate docs, validate queries at build time, and provide editor autocomplete.
What is over-fetching and under-fetching?
Tip: Tie each directly back to how GraphQL solves it — that's the actual point of the question.
Over-fetching is getting more data than you need, common in REST when an endpoint returns a full object. Under-fetching is needing multiple requests to gather all the data you need. GraphQL solves both by letting clients specify exactly which fields they want in one request.
What are resolvers in GraphQL?
Tip: Give one concrete example — like resolving user.posts — it's clearer than an abstract definition.
A resolver is a function that determines how to fetch data for a specific schema field — for example, the resolver for user.posts might query a database for all posts by that user. Each field typically has its own resolver, and the server executes them to build the response.
What is the N+1 query problem, and how is it solved?
Tip: Name DataLoader explicitly — it's the standard expected answer for the "how to solve" part.
The N+1 problem happens when fetching a list triggers a separate query for each item's related data — like fetching 50 users, then querying each one's posts individually. It's typically solved with a batching tool like DataLoader, which groups requests within the same tick into a single batched query.
Query vs Mutation — what's the difference in behavior?
Tip: Mention execution order — mutations run sequentially, queries can run in parallel — that's a commonly missed detail.
A query reads data and shouldn't cause side effects. A mutation modifies data, and unlike queries, mutations are executed sequentially by the GraphQL spec rather than in parallel, since order can matter when multiple mutations affect related data.
What are fragments in GraphQL?
Tip: Frame it as "DRY for queries" — that framing makes the benefit immediately clear.
A fragment is a reusable set of fields on a particular type that you can include in multiple queries, avoiding repeated field selections across queries or components. It keeps client-side code easier to maintain, especially when multiple components need overlapping data.
What is Apollo Client, and what problem does it solve?
Tip: Mention caching specifically — it's usually the standout feature interviewers expect you to know.
Apollo Client is a popular GraphQL client library that handles fetching, caching, and state management for GraphQL data on the frontend. Its normalized cache means if the same piece of data is used in multiple components, it's fetched once and kept in sync automatically.
⭐ Scenario: A GraphQL API is returning slow responses for a specific nested query. How would you investigate?
Tip: This is scenario-based — mention checking for N+1 issues specifically, since that's the most common real-world cause.
Situation: A specific nested GraphQL query — fetching users along with their posts and comments — was noticeably slower than other queries.
Task: I needed to find the actual cause without just assuming it was the database.
Action: I added logging/tracing to the resolvers and found the posts and comments resolvers were each running a separate database query per user, instead of batching — a classic N+1 pattern.
Result: Introducing DataLoader to batch those resolver calls brought the response time down significantly, since it collapsed dozens of per-user queries into a couple of batched ones.
InterviewEra generates role-specific questions using your actual projects and skills. Get scored feedback on technical depth, clarity, and structure — free to start.