Upgrade to Pro — share decks privately, control downloads, hide ads and more …

REST Nem sempre é a melhor opçao

REST Nem sempre é a melhor opçao

Avatar for Eduardo Moroni

Eduardo Moroni

May 22, 2018

More Decks by Eduardo Moroni

Other Decks in Technology

Transcript

  1. DISCLAIMER ➤ I’ll talk about specification not implementation. ➤ Our

    time is short. That’s why I took a simple example to make it clear. ➤ It’s a biased talk. ➤ Based on Cunningham’s law. (https://goo.gl/dmCTQx)
  2. WHAT IS GRAPHQL? ➤ API standard ➤ Enables declarative data

    fetching ➤ Single endpoint to respond queries
  3. GRAPHQL IS THE BETTER REST* ➤ Great ideas in REST:

    stateless servers & structured access to resources ➤ REST is a strict specification - but the concept was wildly interpreted ➤ Rapidly changing requirements on client-side don’t go well with the static nature of REST
  4. WHAT HAS CHANGED SINCE 2000? ➤ Increased mobile usage creates

    need for efficient data loading ➤ Variety of different frontend frameworks and platforms on the client-side ➤ Fast development speed & expectation for rapid feature development
  5. “ You have a client and a server and both

    of them need to talk with each other. The client needs to tell the server what data it needs, and the server needs to fulfil this client’s data requirement with actual data. GraphQL steps into the middle of this communication. -Samer Buna
  6. NO MORE OVER AND UNDERFETCHING ➤ Overfetching: Downloading unnecessary data

    ➤ Underfetching: An endpoint doesn’t return enough of the right information; need to send multiple requests
  7. RAPID PRODUCT ITERATIONS ➤ REST: structure endpoints according to clients’

    data needs ➤ Client speaks a query language not a coordination of HTTP calls. Tell don’t ask principle ➤ No need to adjust API when product requirements and design change ➤ Faster feedback cycles and product iterations
  8. INSIGHTFUL ANALYTICS ➤ Fine-grained info about what data is read

    by clients ➤ Enable evolving API and deprecating unneeded API features ➤ Great opportunities for instrumenting and performance monitoring. ➤ ps: Resolver function to collect data do de shown, instrumentar os resolver provides crucial about bottleneck
  9. BENEFITS OF SCHEMA & TYPES ➤ GraphQL uses strong type

    system to define capabilities of an API ➤ Built-in API documentation ➤ Easy to create contract test, Schema server as contract between client and server ➤ Frontend and backend can work completely independent from each other