GraphQL Fundamentals for Frontend: Shape, Caching, and Tradeoffs
GraphQL lets clients request exactly the data they need. For frontend teams, success depends on proper query design, normalized caching, mutation reconciliation, and schema governance rather than just syntax.
Instead of fixed dishes (REST endpoints), you tell the kitchen precisely which ingredients and portions you need. The challenge is ensuring the kitchen (resolvers) can fulfill requests efficiently and that the delivered meal stays consistent across multiple orders (cache normalization).
1Query Shape and Field Ownership
Clients define exactly which fields they need. Use fragments for reusable field groups. Assign ownership to prevent uncontrolled query growth.
2Normalized Client Cache
Apollo and Relay store entities by __typename + id. This enables consistent updates across views and reduces refetching.
3Mutation Design & Cache Updates
Mutations should return updated entities for automatic cache reconciliation. Use invalidateQueries or setQueryData strategically.
4Pagination and Operational Trade-offs
Use cursor-based pagination. Manage N+1 problems, query complexity limits, and schema evolution carefully.
| Property | REST | GraphQL |
|---|---|---|
| Caching | Excellent HTTP caching | Requires normalization |
| Best For | Simple CRUD | Complex, evolving UIs |
| Complexity | Low | Medium-High |
| Flexibility | Fixed payloads | Client-defined shape |
REST
Caching
Excellent HTTP caching
Best For
Simple CRUD
Complexity
Low
Flexibility
Fixed payloads
GraphQL
Caching
Requires normalization
Best For
Complex, evolving UIs
Complexity
Medium-High
Flexibility
Client-defined shape
Common questions
- ›“What are the main advantages of GraphQL over REST?”
- ›“How does normalized caching work in GraphQL clients?”
- ›“How do you handle mutations and cache updates?”
- ›“What are the operational challenges of GraphQL?”
What interviewers look for
- Understanding of over/under-fetching elimination
- Knowledge of normalized cache and entity identity
- Mutation reconciliation strategies
- Awareness of governance, N+1, and complexity trade-offs
Short answer (60 sec)
GraphQL lets clients request exactly the data needed, eliminating over/under-fetching. Use normalized caching for consistency. Design mutations to return updated entities. Govern schema and query complexity carefully.
Detailed answer (senior level)
GraphQL shifts complexity from endpoint count to schema governance and cache policy. Normalized caching by __typename + id enables efficient updates. Use cursor-based pagination and thoughtful mutation design. Operational concerns include resolver performance, query cost limits, and schema evolution. Strong answers balance flexibility gains with governance responsibility.
- Over-fetching with large fragments
- Poor cache normalization leading to inconsistency
- Not returning updated entities in mutations
- Ignoring N+1 problems in resolvers
- Treating GraphQL as a silver bullet for all APIs
- ✓GraphQL gives precise client-shaped queries
- ✓Normalized cache is critical for UI consistency
- ✓Design mutations to return updated entities
- ✓Use cursor-based pagination for lists
- ✓Governance prevents schema and query sprawl
- ✓Monitor resolver performance and query cost
- ✓Balance flexibility with operational complexity