Semicolony ELI5 · comic

REST vs GraphQL.

A fixed menu where each dish is a separate order, versus telling the kitchen exactly what you want on one plate.

  1. One menu, fixed dishes.
    Menu /users /orders /items
    1

    REST is a fixed menu: each dish lives at its own address — /users, /orders.

  2. Three orders, three trips.
    you api three round trips
    2

    Want three dishes? You place three separate orders and wait for three trips.

  3. I only needed the name.
    wanted this bit got the whole plate
    3

    And each plate arrives whole, even when you only wanted a corner of it.

  4. Just these, please.
    { name orders { total } } ask for exactly this
    4

    GraphQL hands you one order window: write down exactly the fields you want.

  5. One plate, exactly right.
    name + total one plate, one trip
    5

    It all comes back on a single plate, nested data and all, in one round trip.

  6. Can’t cache a custom plate.
    CACHE every order’s different
    6

    The catch: every order is bespoke, so the easy caching REST relies on stops working.

A fixed menu where each dish is its own order, versus one note for exactly what you want.
Semicolony semicolony.dev/eli5/rest-vs-graphql/comic
← All ELI5 explainers