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.

Serverless <3 GraphQL | 2019 - Serverless Architecture Conference

69 views

Published on

Presentation given in Serverless Architecture Conference in the Hague - Netherlands.

Published in: Technology
  • Be the first to comment

Serverless <3 GraphQL | 2019 - Serverless Architecture Conference

  1. 1. Serverless 💚 GraphQL Marcia Villalba @mavi888uy A Match make in heaven
  2. 2. Who I am? @mavi888uy Unicorn.Codes
  3. 3. Marcia VillalbaServerless Architecture Conference Have you seen something like this before?
  4. 4. Marcia VillalbaServerless Architecture Conference POST v1/order POST v2/order GET /order/{orderId} GET /orderDescription/{orderId} GET /orderItems/{orderId} Lots of unnecessary information sent to client Not matching objects GET /order/{orderId} GET /provider/{orderId} GET /customer/{customerId} Bad documentation
  5. 5. Marcia VillalbaServerless Architecture Conference 🤯 As a consumer of those APIs As a maintainer of those APIs
  6. 6. Marcia VillalbaServerless Architecture Conference
  7. 7. Marcia VillalbaServerless Architecture Conference 💜 💚 💚 💚 💜 💜
  8. 8. What is graphql? Let’s talk about the most important concepts
  9. 9. Marcia VillalbaServerless Architecture Conference GraphQL is a specification Not a framework Not a database Not a server
  10. 10. Marcia VillalbaServerless Architecture Conference Query language Runtime
  11. 11. Marcia VillalbaServerless Architecture Conference Graphql Ask for what you need an get exactly that
  12. 12. Marcia VillalbaServerless Architecture Conference Graphql Get many resources in one request
  13. 13. Marcia VillalbaServerless Architecture Conference Graphql Evolve your API without versions
  14. 14. Marcia VillalbaServerless Architecture Conference Graphql Describe what you can do using a type system
  15. 15. Marcia VillalbaServerless Architecture Conference Graphql Connect to multiple datasources Heroes database Planets HTTP service Species noSQL database
  16. 16. Marcia VillalbaServerless Architecture Conference Graphql query language
  17. 17. Marcia VillalbaServerless Architecture Conference Graphql language Everything is a type Fields can be scalar or other types
  18. 18. Marcia VillalbaServerless Architecture Conference Graphql language There are special types
  19. 19. Marcia VillalbaServerless Architecture Conference Graphql language Entry point to the graphql query
  20. 20. Marcia VillalbaServerless Architecture Conference Graphql language The client can write a query like this And get exactly what it needs
  21. 21. Marcia VillalbaServerless Architecture Conference Graphql language Very complete language Read more about it here: https://graphql.org/learn/
  22. 22. Marcia VillalbaServerless Architecture Conference Graphql Runtime
  23. 23. Marcia VillalbaServerless Architecture Conference How graphql works? 1. Describe your data
  24. 24. Marcia VillalbaServerless Architecture Conference How graphql works? 2. Connect all the types and fields to different datasources Videos table Channels table
  25. 25. Marcia VillalbaServerless Architecture Conference How graphql works? 3. Client ask for what it needs
  26. 26. Marcia VillalbaServerless Architecture Conference How graphql works? 4. The server fetches the information from the different datasources Videos table Channels table
  27. 27. Marcia VillalbaServerless Architecture Conference How graphql works? 5. Returns the data
  28. 28. Marcia VillalbaServerless Architecture Conference What are datasources? Can be anything! •A Database •Another service with an API •A HTTP request that return data •A call to a search service •…
  29. 29. Marcia VillalbaServerless Architecture Conference Resolvers Provide the instructions from turning GraphQL operations into data SQL database HTTP service noSQL database
  30. 30. serverless Brief introduction
  31. 31. Marcia VillalbaServerless Architecture Conference No managing infrastructure Pay for what you use Automagical scale
  32. 32. Marcia VillalbaServerless Architecture Conference BACKEND AS A SERVICE (BAAS) Function as a service (FAAS) Serverless
  33. 33. Marcia VillalbaServerless Architecture Conference Backend as a service (BAAS) Backend as a service means a generic application component that is hosted by you or someone else, that you can bundle into your own application using an API.
  34. 34. Marcia VillalbaServerless Architecture Conference Function as a service (FaaS) •Born in 2014 with AWS Lambda •Next evolution of cloud computing •New way to execute and design applications •Function as a service platform
  35. 35. Marcia VillalbaServerless Architecture Conference https://read.acloud.guru/the-serverless-spectrum-147b02cb2292
  36. 36. Marcia VillalbaServerless Architecture Conference Benefits of serverless •Pay for what you use •Not reinventing the wheel •Fast development •High integration with different services •Not worrying about infra •All about providing value
  37. 37. Marcia VillalbaServerless Architecture Conference - Steve Jobs “The line of code you don’t write is the line of code you never have to debug”
  38. 38. serverless and graphql Why they are a match made in heaven?
  39. 39. Marcia VillalbaServerless Architecture Conference Graphql & serverless Implement your own GraphQL server Use an existing GraphQL server library Use an existing GraphQL platform
  40. 40. Marcia VillalbaServerless Architecture Conference Existing GraphQL platforms •Apollo Platform (https://www.apollographql.com/ platform/) •GraphCMS (https://graphcms.com/) •GraphCool (https://www.graph.cool/) •AppSync (https://aws.amazon.com/appsync/)
  41. 41. AWS AppSync A Serverless GraphQL platform
  42. 42. Marcia VillalbaServerless Architecture Conference Managed graphql platform by aws
  43. 43. Marcia VillalbaServerless Architecture Conference appSync •Provides authentication •Visual tool for queries •Automatic connection with DynamoDB tables •Different datasources - AWS Lambda, Elastic Search, Aurora DB, HTTP •Real time and off-line support
  44. 44. Marcia VillalbaServerless Architecture Conference Creates a schema
  45. 45. Marcia VillalbaServerless Architecture Conference Connect to different datasourcesCreates a schema
  46. 46. Marcia VillalbaServerless Architecture Conference Connect to different datasourcesCreates a schema Updates data in real time in different devices
  47. 47. Marcia VillalbaServerless Architecture Conference
  48. 48. Marcia VillalbaServerless Architecture Conference Infrastructure as code •Serverless Framework •Serverless Framework plugin for AppSync (https:// github.com/sid88in/serverless-appsync-plugin)
  49. 49. Marcia VillalbaServerless Architecture Conference Lets go to the code…
  50. 50. Marcia VillalbaServerless Architecture Conference AWS Cloud Client AWS AppSync AWS Lambda Amazon DynamoDB VLT mappers for request and response VLT mappers for request and response
  51. 51. Marcia VillalbaServerless Architecture Conference
  52. 52. Marcia VillalbaServerless Architecture Conference How the client uses this? •AWS Amplify •Client library for building cloud apps •More info: https://aws-amplify.github.io/docs/js/ api#aws-appsync-sdk
  53. 53. Marcia VillalbaServerless Architecture Conference Configure the client
  54. 54. Marcia VillalbaServerless Architecture Conference Run a query
  55. 55. Marcia VillalbaServerless Architecture Conference Things to have in mind •If you do a DynamoDB scan be careful of performance •Calling a cold AWS Lambda •Doing an HTTP call ads latency to the response •Think about when calling other services from AWS Lambda how much latency you are adding to the whole system
  56. 56. Marcia VillalbaServerless Architecture Conference Conclusion •Fast development •Easily maintainable •Secure applications •Scalable applications •Pay as much as we use
  57. 57. @mavi888uy
  58. 58. Marcia VillalbaServerless Architecture Conference New course! •Serverless Applications with GraphQL on AWS •Follow me on twitter to get notified when it is out: @mavi888uy

×