Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GraphQL is actually rest

80 views

Published on

Slides to talk presented on #ngpartycz about the history of APIs, evolution and how to pick the right technology for you. It might not be (and probably will not be) the technically best solution. And of course you will find out why is GraphQL actually REST.

Published in: Technology
  • Be the first to comment

GraphQL is actually rest

  1. 1. If you know what I mean GRAPHQL IS ACTUALLY REST
  2. 2. JAKUB RIEDL Software Engineer @iflix lead of GraphQL project
  3. 3. In we redefine television for a billion people
  4. 4. WHY DO WE NEED API?
  5. 5. WHY DO WE NEED API? TO TRANSFER STATE BETWEEN BACKEND AND FRONTEND
  6. 6. 1999 SOAP HISTORY OF WEB API TECHNOLOGIES 2000 REST 2007 OData 2015 GraphQL Falcor 2013 JSON API
  7. 7. ● A protocol ● XML Based ● RPC methods ● Usually over HTTP or SMTP SOAP Standard Object Access Protocol (1999)
  8. 8. SOAP Standard Object Access Protocol (1999)
  9. 9. ● Architectural style introduced by Roy Fielding in his PhD dissertation ● Most commonly uses JSON ● Centered around resources ● Usually over HTTP REST Representational State Transfer (2000)
  10. 10. ● Client - Server ● Stateless ● Cacheable ● Layered System ● Uniform Interface ○ Identification of resources ○ Manipulation of resources through these representations ○ Self-descriptive messages ○ Hypermedia as the engine of application state REST ARCHITECTURAL CONSTRAINTS
  11. 11. REST Representational State Transfer (2000)
  12. 12. RESTful One endpoint per resource Users CommentsPosts Browser AndroidiOS - Server centric Pros - Flexible - Easy to implement - Decoupled features Cons - Coupled BE w/ FE - Lots of roundtrips - Over-fetching - Inconsistent - Complex clients
  13. 13. - Client centric (ish) Pros - One round trip - Exactly what you need Cons - Inflexible - Inconsistent - Expensive - Slow to iterate REST-ish One endpoint per view (Backend for frontend) View A (web) View C (mobile) View B (web) Browser AndroidiOS
  14. 14. RESTful One gateway with resources Users CommentsPosts Browser AndroidiOS Standardized API Layer Pros - Flexible - Decoupled - No extra roundtrips - Consistent - Easier for clients Cons - Single point of failure - Perf overhead
  15. 15. STANDARDIZATION 1960 2016
  16. 16. Users CommentsPosts Browser AndroidiOS Requirements - Client centric - Minimize roundtrips - Reduce data transfer - Flexible - Decoupled - Consistent ?
  17. 17. Users CommentsPosts Browser AndroidiOS Real Requirements - Fast to iterate - Time to market - Developer experience - Tooling - Docs ?
  18. 18. ● $select: choose which fields you want ● $expand: fetch related resources ● $top + $skip: pagination ● $filter (eq, lt, startswith, ...): server-side filtering ● $metadata: introspection + discovery ODATA “The best way how to REST” * * says Microsoft
  19. 19. ODATATM
  20. 20. ODATATM
  21. 21. ODATATM £9.59 per month
  22. 22. ● All data modelled as a JSON object with references ● All values resolve asynchronously ● “Routes” determine how data is fetched ● Data is treated as graph ● Easy to learn & use ● No type system, no arguments ● Limited tooling FALCOR
  23. 23. FALCOR
  24. 24. ● “The clean way” ● Leverages features of HTTP (caching, content negotiation, ...) ● Not typed by default ● Limited tooling JSON API
  25. 25. JSON API
  26. 26. ● Easy-to-use query language ● Strongly typed = consistent ● Very popular last months ● Great tooling ● Ready made clients ● Great developer experience ● Complexity comes with scale GRAPHQL
  27. 27. GRAPHQL developer.iflix.com real world example
  28. 28. ● Client - Server ● Stateless ● Cacheable ● Layered System ● Uniform Interface ○ Identification of resources ○ Manipulation of resources through these representations ○ Self-descriptive messages ○ Hypermedia as the engine of application state IS GRAPHQL RESTful?
  29. 29. ● Every object/resource has a globally unique id ● Every resource can be retrieved given its id NODE INTERFACE
  30. 30. NODE INTERFACE
  31. 31. Uniform interface ● Identification of resources ● Manipulation of resources through these representations ● Self-descriptive messages ● Hypermedia as the engine of application state GRAPHQL + NODE INTERFACE == RESTful
  32. 32. WHAT TO CHOOSE?
  33. 33. WHAT TO CHOOSE? IT DEPENDS.
  34. 34. SUMMARY
  35. 35. SUMMARY REST IS NOT A STANDARD
  36. 36. SUMMARY REST IS NOT A STANDARD FOCUS ON YOUR NEEDS
  37. 37. THANKS TO JONAS HELFER: GRAPHQL - EVOLUTION OR REVOLUTION?
  38. 38. 3 8 WE ARE HIRING .com
  39. 39. jakubriedl.com @jakubriedl jakubriedl jakubriedl GET IN TOUCH

×