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

The Future of Rails - Take 2

The Future of Rails - Take 2

The 2nd version of my talk on the Future of Rails. A more streamlined version.

Ryan Bigg

May 10, 2018
Tweet

More Decks by Ryan Bigg

Other Decks in Programming

Transcript

  1. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd

    Content-Id:<[email protected]> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd-- In the past… (1998) SOAP APIs
  2. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd

    Content-Id:<[email protected]> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd-- SOAP APIs In the past… (1998)
  3. Retrieved: Tuesday, 8th May, 2018. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0'

    encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Id:<[email protected]> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd--
  4. JSON “Sure, here’s my data” Third Party App Your App

    [ { "User/Employee ID": "ryan001", "First Name": "Ryan", "Username": "ryanbigg", . . . } . . . ]
  5. A browser JavaScript, CSS, Images, and Rails The Monolith And

    then and then (circa 2011) Database Makes your app look great Makes your app do stuff
  6. A browser React App Frontend App Backend App Now… (2018)

    Database Rails App Makes your app look great Makes your app do stuff
  7. A browser React App Frontend App Backend App Now… (2018)

    Database Rails App SeparaEon of Concerns
  8. A browser Frontend App Backend App “Views”, CSS, JS, etc.

    Controllers, models, etc. React App Database Rails App Now… (2018)
  9. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg" } JSON APIs
  10. A browser React App /api/posts/:id /api/comments … Currently… JSON APIs

    Need to build lots of these… Database Rails App /api/posts
  11. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg" } JSON APIs Problem #1
  12. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg”, “comments”: [ { “id”: 1, ... } ] } JSON APIs Problem #2
  13. Facebook iOS App Facebook Servers 1. Get news feed items

    2. Here are your items 3. Get comments 4. Here are the comments 5. Fetch user data 6. Here are the users
  14. /graphql Now (and the future) Only one endpoint (born 2012)

    Database Rails App A browser React App
  15. Fetching a Post query postQuery { post(id: 1) { id

    title body author } } { "data": { "post": { "id": 1, "title": "Hello World", "body": "First post!”, "author": "Ryan Bigg", } } } Query Response GRAPHQL
  16. query postQuery { post(id: 1) { id title body author

    } } { "data": { "post": { "id": 1, "title": "Hello World", "author": "Ryan Bigg", } } } Query Response GRAPHQL Ignoring a field
  17. Post + Comments query postQuery { post(id: 1) { id

    title body author comments { text by } } } { "data": { "post": { "id": 1, "title": "Hello World", "body": "First post!”, "author": "Ryan Bigg", "comments": [ { text: "Great first post!", by: "Totally not Ryan" }, ... ] } } } Query Response GRAPHQL
  18. query postQuery { ... } query commentQuery { comment(id: 1)

    { text user } } { "data": { “post”: { ... }, “comment”: { text: "Great first post!", user: "Totally not Ryan” } } } Query Response GRAPHQL Two queries at the same Eme
  19. Facebook iOS App Facebook Servers 1. Get news feed items,

    their comments and their users 2. Here’s everything