Switching from REST to GraphQL for the mobile app: lessons learned
Six months ago we migrated the DESIRIY mobile app from a REST API to GraphQL. This is what we learned.
The primary motivation was over-fetching. Our home feed endpoint returned 47 fields per Moment. The mobile app used 12 of them. On a slow mobile connection over three hours of usage, that is hundreds of kilobytes of wasted data per session.
With GraphQL, the client declares exactly what it needs. The server returns exactly that. For the home feed, payload size dropped by 61%.
The challenges were real though:
- **N+1 query problem.** Our first GraphQL implementation had catastrophic N+1 database queries. We solved this with DataLoader batching, reducing database roundtrips by 89%.
- **Cache invalidation.** REST has predictable cache keys (the URL). GraphQL does not. We built a normalised client-side cache keyed on entity type and ID, with per-field TTLs.
- **Error handling.** GraphQL always returns HTTP 200. Our existing error monitoring was based on HTTP status codes. We had to instrument at the resolver level instead.
Overall: the right decision. App performance improved measurably. The main cost was migration time and educating the team on GraphQL patterns.