skip to content

In a frontend design round for a retail-banking web app, how would you choose REST, GraphQL or RPC for its overview, transactions and transfer screens?

level: middleimportance: must knowfreq 62%

answer

  1. argue per screen, not per app
  2. list: a collection plus query parameters
  3. transfer: a command with an idempotency key
  4. overview: three sources, one round trip
  5. GraphQL pays off as screens multiply

basics

~20 s

Argue it from the screens: the transactions list is a filtered, paged resource (REST), the transfer is a command (an action endpoint), and the overview's three-source fan-in decides whether GraphQL or one screen-shaped endpoint earns its cost.

solid answer

~40 s

I'd argue it per screen. The transactions list is a filtered, paged collection, so a REST collection with query parameters fits: safe `GET`s, filters that mirror the page URL, cheap conditional refreshes. The transfer is a command: a `POST /transfers` carrying a client-generated idempotency key, because `POST` is not idempotent and a retried submit must not move money twice. The overview decides the argument: it fans in from three services, so I'd give it one screen-shaped endpoint composed on the server rather than three browser calls. GraphQL would also collapse it to one round trip, but with three fixed screens and one web client it adds a schema, a server and a different error model for little gain. I'd revisit that if many screens start combining the same entities in different shapes.

go deeper

for a junior

Recall that each screen's need, reading a collection, running a command or combining sources, points to a different contract shape.

for a middle

Explain it per screen: a collection with parameters, a POST command with an idempotency key, and how the overview reaches one round trip either way.

for a senior

Show what each style costs the client in error model, caching and round trips, and name the condition that would move the overview to GraphQL.

for a principal

Weigh one consistent HTTP API against a graph serving many screens and clients, including who keeps shipping composite endpoints as the product grows.

## Start from the screens, not from the style In the interface step of a frontend design round, the "REST, GraphQL or RPC?" question is answered best by walking the screens one at a time and asking what each needs from the server: how many entities, how many sources, whether it reads or changes something, and how often its shape will change. A **retail-banking web app** has three screens worth arguing: | Screen | What it needs | Natural contract shape | |---|---|---| | Accounts overview | Balances, cards and offers from three back-end services, shown together | One screen-shaped read combining three sources | | Transactions list | A filtered, paged collection, thousands of rows per account | A collection resource with filter and page parameters | | Money transfer | A command with side effects and server-side validation | An action endpoint that creates a transfer | Three screens, three shapes. The choice is not "one style for the whole app because it is fashionable" but which style serves the hardest screens, and whether mixing shapes inside one HTTP API costs anything. Usually it does not. ## The transactions list: a resource with parameters The list reads a collection, filtered by date range and category, and paged. That maps cleanly onto a REST collection such as `GET /accounts/{id}/transactions?from=…&to=…&category=…`, returning a page of rows and a pointer to the next page. What the client gains: - the screen's filters can live in the page URL and map one-to-one onto the request's query parameters; - `GET` is a **safe** method in HTTP semantics (the client requests no state change), so it can be repeated or prefetched without fear; - conditional requests (`If-None-Match` with an entity tag) let a refresh come back as `304 Not Modified` when nothing changed. GraphQL can express the same list, but it buys little here: the list's shape is fixed and known in advance. ## The transfer: a command, not a field selection Submitting a transfer moves money. It is a **command**, and the contract should say so: `POST /transfers` with source, destination, amount and a client-generated **idempotency key**, answered with the created transfer or a validation error. HTTP semantics define `PUT`, `DELETE` and the safe methods as idempotent, and `POST` is not, so a retry after a lost response could repeat the transfer unless the server deduplicates on that key. Whether you call this REST (creating a transfer resource) or RPC (a `submitTransfer` procedure) matters less than its properties: one round trip, per-field validation errors and a safe retry. In GraphQL it would be a mutation; the specification describes a query as a read-only fetch and a mutation as a write followed by a fetch, and the same idempotency concern applies. ## The overview: where the styles really differ The overview combines three sources, and that is where the options diverge: 1. **Three calls from the browser**, one per service, stitched on the client. Cheapest for the API side; the client pays three requests, three error shapes and the stitching. 2. **One screen-shaped endpoint** such as `GET /overview`, composed on the server by the API team or by a backend-for-frontend. 3. **A GraphQL query** over a schema spanning the three services, the screen selecting exactly the fields it shows. Options 2 and 3 both reduce the screen to one round trip. GraphQL's advantage appears when many screens, or several clients, combine the same entities in different shapes; with three fixed screens and one web client, a single composed endpoint delivers the same round trip with less machinery. ## What each style costs the client | Style | What the client gains | What the client pays | |---|---|---| | REST resources | Safe `GET`s, status codes, conditional requests | Several calls when a screen spans resources, unless a composite endpoint exists | | GraphQL | One query per screen, exactly the fields it shows | A schema and server to run; field errors arrive beside data instead of as a status code; HTTP caching needs extra work when queries are sent as `POST` | | RPC | Plain function-shaped calls, a natural fit for commands | No shared resource conventions; each call's safety and retry rules must be documented one by one | ## The recommendation, and what would change it For this app: REST collections for the list, a command endpoint for the transfer, and one composed overview endpoint, all in one HTTP API with one error envelope. Revisit it when: - more screens combine accounts, cards and offers differently, and every new screen waits on another composite endpoint; - the API team can no longer keep pace shipping screen-shaped endpoints for frontend changes. The general choice among styles at any service surface is a neighbouring subject; in the round, the credit goes to arguing it from these screens and naming what each choice costs the client.

  • The product adds a dashboard and a statements page that combine accounts, cards and offers in new ways. Does your answer change?
    It starts to. Each new screen asking for its own composite endpoint means the API team ships an endpoint per screen and the frontend waits on it. Once combinations multiply, a GraphQL schema over the three sources lets each screen select its own fields without a new endpoint, at the price of running the schema and adopting its partial-error model. I'd switch when that endpoint backlog is the bottleneck, not before.
  • Why not three parallel browser calls for the overview, since parallel requests do not wait on each other?
    Parallel calls avoid a waterfall, but the client still pays three requests on a phone network, three authentication paths, three error shapes and the stitching, and it must decide alone what to show when one fails. Composing on the server does the fan-out on a fast internal network and returns one envelope. Three calls stay reasonable when the services already share one origin, one session and one error format.

  • Picking GraphQL for the whole app because it is the modern default
  • Saying a REST API cannot express a filtered, paged list
  • Sending a transfer as a GET so retries are harmless
  • Assuming one style must serve every screen of the app
  • Claiming only GraphQL can return partial data for a fan-in screen