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 over REST

87 views

Published on

GraphQL over REST Presentation for LetSwift 2018

Published in: Mobile
  • Be the first to comment

  • Be the first to like this

GraphQL over REST

  1. 1. The Evolution of API Design
  2. 2. API History New API Standard GraphQL over REST GraphQL Fundamentals
  3. 3. Application
  4. 4. Application Database
  5. 5. Application DatabaseServer
  6. 6. rogramming pplication nterface
  7. 7. Socket Programming Socket
  8. 8. Remote Procedure Call XML-RPC
  9. 9. XML-RPC Remote Procedure Call
  10. 10. Remote Procedure Call XML-RPC
  11. 11. Simple Object Access Protocol SOAP SOAP-ENV : Envelope SOAP-ENV: Header SOAP-ENV: Body
  12. 12. Simple Object Access Protocol SOAP
  13. 13. REpresentational State Transfer REST
  14. 14. REST
  15. 15. • Need for efficient data loading
  16. 16. • Need for efficient data loading • Variety of different frontend platforms
  17. 17. • Need for efficient data loading • Variety of different frontend platforms • Fast & Iterative development
  18. 18. With GraphQL, you model your business domain as a graph
  19. 19. A Query Language for your APIQuery Language
  20. 20.
  21. 21. • New API Standard invented by Facebook
  22. 22. • New API Standard invented by Facebook • Presented publicly at React.js Conf 2015
  23. 23. • New API Standard invented by Facebook • Presented publicly at React.js Conf 2015 • Declarative Data Fetching
  24. 24. • New API Standard invented by Facebook • Presented publicly at React.js Conf 2015 • Declarative Data Fetching • Single Endpoint, Single Request
  25. 25. • New API Standard invented by Facebook • Presented publicly at React.js Conf 2015 • Declarative Data Fetching • Single Endpoint, Single Request • Strong Type System
  26. 26. Open Source License BSD + Patents
  27. 27. Open Source License BSD + Patents
  28. 28. Open Source License BSD + Patents
  29. 29. Open Source License OWFa v1.0
  30. 30. https://developer.github.com/v3/ https://developer.github.com/v4/
  31. 31. User Name
  32. 32. User Name Post Title
  33. 33. User Name Post Title Follower Name
  34. 34. /users/<id> /users/<id>/posts /users/<id>/followers
  35. 35. /users/<id> /users/<id>/posts /users/<id>/followers Fetch user data
  36. 36. /users/<id> /users/<id>/posts /users/<id>/followers Fetch user data
  37. 37. /users/<id> /users/<id>/posts /users/<id>/followers Fetch posts
  38. 38. /users/<id> /users/<id>/posts /users/<id>/followers Fetch posts
  39. 39. /users/<id> /users/<id>/posts /users/<id>/followers Fetch followers
  40. 40. /users/<id> /users/<id>/posts /users/<id>/followers Fetch followers
  41. 41. /graphql
  42. 42. /graphql Fetch everything with a single request
  43. 43. /graphql Fetch everything with a single request
  44. 44. • Underfetching (N + 1 requests problem)
  45. 45. /users/<id> /users/<id>/posts /users/<id>/followers /users/<id> /users/<id>/posts /users/<id>/followers /users/<id> /users/<id>/posts /users/<id>/followers
  46. 46. /graphql
  47. 47. • Underfetching (N + 1 requests problem) • Nested CompletionHandler
  48. 48. • Underfetching (N + 1 requests problem) • Nested CompletionHandler
  49. 49. • Underfetching (N + 1 requests problem) • Nested CompletionHandler • Overfetching
  50. 50. . . .
  51. 51. . . .
  52. 52. . . .
  53. 53. • Underfetching (N + 1 requests problem) • Nested CompletionHandler • Overfetching • Too Many Endpoints
  54. 54. Clients /users /usersInfo /usersCount /userPosts
  55. 55. /users /usersInfo /usersCount /userPosts /userFollowers Clients /userByPost /userNameStartsK
  56. 56. • Underfetching (N + 1 requests problem) • Nested CompletionHandler • Overfetching • Too Many Endpoints • Versioning
  57. 57. • Underfetching (N + 1 requests problem) • Nested CompletionHandler • Overfetching • Too Many Endpoints • Versioning • Schemaless
  58. 58. • Underfetching (N + 1 requests problem) • Nested CompletionHandler • Overfetching • Too Many Endpoints • Versioning • Schemaless • Slow Product Development
  59. 59. User Requests (per hour) Authenticated 5000 Unauthenticated 60
  60. 60. User Requests (per hour) Authenticated 5000 Unauthenticated 60
  61. 61. User Requests (per hour) Authenticated 5000 Unauthenticated 60
  62. 62. • Node Limit
 Individual Call ≦ 500,000 total nodes
  63. 63. • Node Limit • Rate Limit
 5,000 points per hour (points ≠ call)
  64. 64. 1
  65. 65. 1 100
  66. 66. 1 100 5000
  67. 67. 1 100 5000 5101
  68. 68. 1 100 5000 5101 / 100 = 51
  69. 69. Server
  70. 70. Server
  71. 71. Server Connection
  72. 72. Server Connection
  73. 73. Server Connection
  74. 74. Architectural Style HTTP, HTTPS Protocol Multiple Endpoints Schemaless Fixed Data Structure Versioning Standard API Transport Layer Agnostic Single Endpoint Strongly Typed Schema Flexible Data Structure Evolve API Without Versions

×