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

Forget about the REST

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Forget about the REST

Small presentation about GraphQL and Rails

https://github.com/adamors/pizza

http://adams.pizza/graphiql

Avatar for Adam Kovacs

Adam Kovacs

July 27, 2017

Other Decks in Programming

Transcript

  1. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 2

    Rails to the future Forget about the REST What are we going to discuss - REST - How do we work with RESTful APIs - Painpoints - GraphQL
  2. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 3

    Rails to the future Forget about the REST REST - Boring Definition - Client-server architecture - Statelessness - Cacheability
  3. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 4

    Rails to the future Forget about the REST REST in Rails - Convention over configuration - CRUD like interface - Actions on resources - The Rails Way
  4. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 5

    Rails to the future Forget about the REST Rails 5 - API only mode - Active Model Serializers - JSON JSON JSON - SPA friendly
  5. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 6

    Rails to the future Forget about the REST adams.pizza - RESTful toy app - List pizzas - Review pizzas
  6. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 8

    Rails to the future Forget about the REST Rest backends - Versioning PIA - Server defines what is returned - Change is hard - “Pure” restful apps are hard to do
  7. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 9

    Rails to the future Forget about the REST Rest backends - GET /pizzas - GET /pizzas/1 - GET /pizzas/1/toppings - GET /pizzas/1/reviews
  8. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 10

    Rails to the future Forget about the REST Rest backends - GET /pizzas?include=tags,reviews - Return everything - Custom endpoints
  9. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 12

    Rails to the future Forget about the REST Documenting restful - Apipie - Swagger - API Blueprint - RAML - Heroku stack -
  10. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 13

    Rails to the future Forget about the REST Request/Response validation - JSON Schema - Hard to automate - Committee gem
  11. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 14

    Rails to the future Forget about the REST Graphql - Developed by Facebook to solve their problems with mobile apps - Graph structure + query language (like SQL) - Client defines what is returned - Change is embraced - Easy-peasy?
  12. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 15

    Rails to the future Forget about the REST Graphql - Format validation built in - Living documentation - API can be explored
  13. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 16

    Rails to the future Forget about the REST Graphql - Queries (reads) - Mutations (writes) - One endpoint - No GET/POST/PUT/PORC nonsense
  14. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 17

    Rails to the future Forget about the REST Graphql - Queries (reads) - Mutations (writes) - One endpoint - No GET/POST/PUT/PORC nonsense
  15. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 18

    Rails to the future Forget about the REST Graphql
  16. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 19

    Rails to the future Forget about the REST Graphql
  17. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 20

    Rails to the future Forget about the REST Graphql - Easy to set up - Graphql gem - Living specification - Validation built in through and through
  18. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 22

    Rails to the future Forget about the REST Graphql
  19. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 23

    Rails to the future Forget about the REST Graphql - Resolvers - Javascript flavoured - Complexity underneath
  20. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 24

    Rails to the future Forget about the REST Graphql - N+1 queries - Can overwhelm the server - Caching has to be done on the client side
  21. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 25

    Rails to the future Forget about the REST Shopify’s batch loader Graphql
  22. COPYRIGHT © 3PILLAR GLOBAL - PROPRIETARY AND CONFIDENTIAL INFORMATION 26

    Rails to the future Forget about the REST Graphql - Ecosystem young and immature - Spec is constantly evolving - Large adopters: GitHub, Shopify - https://www.howtographql.com