build scalable apis using graphql and serverless simona
play

Build Scalable APIs using GraphQL and Serverless @simona_cotin - PowerPoint PPT Presentation

Build Scalable APIs using GraphQL and Serverless @simona_cotin @simona_cotin @simona_cotin JS @simona_cotin @simona_cotin @simona_cotin @simona_cotin a data-fetching API powerful enough to describe all of Facebook -Lee Byron


  1. Build Scalable APIs using GraphQL and Serverless

  2. @simona_cotin

  3. @simona_cotin

  4. @simona_cotin

  5. JS @simona_cotin

  6. @simona_cotin

  7. @simona_cotin

  8. @simona_cotin

  9. a data-fetching API powerful enough to describe all of Facebook –-Lee Byron @simona_cotin

  10. @simona_cotin

  11. https://facebook.com/user/id https://facebook.com/user/id/events https://facebook.com/user/id/friends-suggestions https://facebook.com/user/id/friends-birthdays @simona_cotin

  12. https://facebook.com/user/id/events { "name": “ServerlessDays", "location": "Cardiff", "organiser": "Matt", "attendees": [ { "name": “Ant Stanley", "company": "  ", "role": “Father of ServerlessDays” } ] } @simona_cotin

  13. @simona_cotin

  14. Overfetch Or New endpoint @simona_cotin

  15. @simona_cotin

  16. https://facebook.com/user/id/friends-suggestions { "name": "Golnaz Badazadeh", "profile_pic": "some_url", "mutual_friends": [] } @simona_cotin

  17. https://facebook.com/user/id/friends-suggestions/id/mutual { "mutual_friends": [ { "name": "Sarah Drasner", "profile_pic": "some_url", "tag": "Amazing!" } ] } @simona_cotin

  18. Underfetch Or New endpoint @simona_cotin

  19. Delay User Perception 0-100 ms Instant 100-300 ms Small perceptible delay 300-1000 ms Machine is working 1000+ ms Likely context switch 10000+ ms Task is abandoned High performance Browser Networking @simona_cotin

  20. The fastest network request is a request not made –-Ilya Grigorik @simona_cotin

  21. query { { user(id:1) { "data": { name "user": { events { "name": "Simona Cotin", count "events": { } "count": 4 friends_suggestions { }, name "friends_suggestions": { mutual_friends { "name": "Golnaz Babazadeh", count "mutual_friends": { } "count": 15 } } } } } } } } @simona_cotin

  22. Schema driven development @simona_cotin

  23. Strongly typed @simona_cotin

  24. type People { id: ID! name: String avatar: URL } @simona_cotin

  25. type People { id: ID! name: String avatar: URL } type Team { id: ID! name: String points: Int people: [People] } @simona_cotin

  26. type Query { teams: [Team] } type Mutation { incrementPoints(id: ID!): Team } @simona_cotin

  27. const root = { teams: async () =?� { let teams = await axios.get( 'https://graphqlvoting.azurewebsites.net/ api/score' ); return teams.data; }, incrementPoints: async obj =?� { let response = await axios.get( `https://graphqlvoting.azurewebsites.net/ api/score/${obj.id}` ); return response.data; } }; @simona_cotin

  28. @simona_cotin

  29. @simona_cotin

  30. @simona_cotin

  31. ✓ Performance ✓ Flexibility ✓ Tooling @simona_cotin

  32. Serverless @simona_cotin

  33. The line of code that’s the fastest to write, that never breaks, that doesn’t need maintenance, is the line you never had to write. –-Steve Jobs @simona_cotin

  34. module.exports = async function(context, req) { context.res = { body: 'Hello ' + req.query.name }; }; @simona_cotin

  35. Right-Click Deploy @simona_cotin

  36. Github Deploy @simona_cotin

  37. @simona_cotin

  38. Datasources 3rd party APIs @simona_cotin

  39. @simona_cotin

  40. { "type": "cosmosDB", "name": "inputDocument", "databaseName": "admin", "collectionName": "Recipes", "connectionStringSetting": "tacos-sql_DOCUMENTDB", “direction": "in" } @simona_cotin

  41. module.exports = async function(context, req) { context.res = { body: context.bindings.inputDocument }; }; @simona_cotin

  42. ✓ Reusable API ✓ VS Code dev & debug ✓ Easy Integration Datasources @simona_cotin

  43. No servers to manage @simona_cotin

  44. Serverless @simona_cotin

  45. @simona_cotin

  46. @simona_cotin

  47. @simona_cotin

  48. @simona_cotin

  49. @simona_cotin

  50. module.exports = async function(context, req) { const body = req.body; let response = await graphql( typeDefs, body.query, root, null, body.variables, body.operationName ); context.res = { body: response }; }; @simona_cotin

  51. @simona_cotin

  52. @simona_cotin

  53. @simona_cotin

  54. @simona_cotin

  55. Serverless GraphQL Easy Abstraction of Datasources Easy Integration of Datasources Single Endpoint Autoscalability Less code Smaller no requests @simona_cotin

  56. Dev productivity Easy Integration of Datasources Easy Abstraction of Datasources Autoscalability Single Endpoint Less code Smaller no requests @simona_cotin

  57. Achieve more by doing less @simona_cotin

  58. https://github.com/simonaco/serverless- graphql-workshop @simona_cotin

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend