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 and AWS AppSync (Serverless GraphQL service)

183 views

Published on

GraphQL has become the API of choice for many leading technology companies. In 2018 AWS made its’ managed GraphQL service, AWS AppSync, generally available. In this talk we discussed:

* What GraphQL is
* Why it is being adopted
* What AWS AppSync is and how it works
* Where AWS AppSync fits into the broader AWS serverless landscape.

Presenter Bio: Peter Dyer is a Freelancer and https://www.fullsapps.com/ contributor. You can follow him on Twitter @peter_dyer.

More info about the event: https://www.linkedin.com/feed/update/urn:li:activity:6500574686257168384

Join www.ServerlessToronto.org community to learn how to leverage Serverless Architectures in order to innovate faster, and make your apps scalable & cost-effective!

Published in: Software
  • Be the first to comment

GraphQL and AWS AppSync (Serverless GraphQL service)

  1. 1. Join www.ServerlessToronto.org Home of “Less IT Mess”
  2. 2. Manning Publications 2019 giveaways: 1. www.manning.com/books/serverless-applications-with-nodejs 2. www.manning.com/livevideo/production-ready-serverless 3. www.manning.com/livevideo/production-ready-serverless 4. www.manning.com/livevideo/serverless-applications-with-AWS 5. www.manning.com/livevideo/serverless-applications-with-AWS 6. www.manning.com/books/serverless-architectures-on-aws 7. www.manning.com/books/http2-in-action 8. www.manning.com/books/event-streams-in-action 9. www.manning.com/books/the-design-of-everyday-apis 10. www.manning.com/livevideo/graphql-in-motion 11. www.manning.com/books/voice-applications-for-alexa-and-google-assistant 12. www.manning.com/livevideo/machine-learning-for-mere-mortals 2
  3. 3. Tuesday, Jan 29, 2019 1. Introduction 2. Community Open Mic 3. Presentation: Peter Dyer GraphQL, AWS AppSync and AWS Serverless 4. Networking 3 Serverless Toronto Meetup Agenda
  4. 4. Community Open Mic 4 10 seconds of freedom to pitch yourself, or your company
  5. 5. GraphQL, AWS AppSync and AWS Serverless
  6. 6. Who am I Peter Twenty years working in software ● Majority for small software companies ● Majority as a technical product manager Currently focused on fullstack development (opinionated about the stack)
  7. 7. Backend-as-a-Service / Serverless I want interactive software in the hands of users ASAP I want to take advantage of the code that others have written (services or libraries) Humans are almost always the most expensive part of development (At scale, things are different)
  8. 8. My view of Serverless Authentication Database Storage Hosting Functions APIs Analytics Machine Learning Notifications PubSub Etc
  9. 9. Intro to GraphQL
  10. 10. What is GraphQL? “A query language for your API” Originated in Facebook (2012) Open-source specification (2015) “Competitor” to REST Source: https://graphql.org/
  11. 11. Why GraphQL? Ask for what you want, and get only that Get many resources in a single request Discoverability (documentation) is built in Avoid API versioning It’s just the API
  12. 12. Who is using GraphQL ● Netflix ● New York Times ● AirBnB ● Telus ● Etc Source: https://graphql.org/
  13. 13. vs REST In common ● HTTP ● JSON ● Just API ● Good tooling GraphQL Improvements ● No over-fetching ● No under-fetching ● No (limited) need for versioning ● Documentation is built in
  14. 14. Star Wars REST https://swapi.co/ GraphQL https://graphql.github.io/swapi-graphql/
  15. 15. Star Wars - list people (just names) REST https://swapi.co/api/ people Result: 7,447 characters (for page 1, 10 of 87 people) GraphQL https://graphql.github.io/swapi-graphql/ query { allPeople { people { name } } } Result: 4,916 characters
  16. 16. Star Wars - name of Luke’s films REST https://swapi.co/api/ people/1 films/1/ films/2/ films/3/ films/6/ films/7/ Result: ~2,500 characters per request (6 requests) GraphQL https://graphql.github.io/swapi-graphql/ query { person(id: "cGVvcGxlOjE=") { name filmConnection { films { title } } } } Result: 492 characters
  17. 17. Star Wars - add shoe_size field to people REST Every ‘good’ implementation breaks, or new API version Someone needs to update the documentation GraphQL Nothing breaks, anyone who wants to can start using the new field Documentation has been automatically updated
  18. 18. GraphQL terminology ● Type system ● Schema ● Queries ● Mutations ● Subscriptions ● Resolver ● Client & Server
  19. 19. The GraphQL challenge ● Bad queries ○ Depth problems ○ Too much data
  20. 20. AWS AppSync
  21. 21. AWS AppSync Amazon’s GraphQL service https://aws.amazon.com/appsync/ “AWS AppSync is a serverless back-end for mobile, web and enterprise applications”
  22. 22. Architecture Source: https://docs.aws.amazon.com/appsync/latest/devguide/system-overview-and-architecture.html
  23. 23. How it works Resolvers "translate" GraphQL to do something with a "Data Source" Data Sources = DynamoDB, Lambda, ElasticSearch, Aurora, HTTP Translation via VTL (Apache Velocity Template Language)
  24. 24. AWS AppSync Walk-through
  25. 25. Steps 1. Create Lambda function(s) that will “resolve” API request a. Use Events to pass in arguments 2. Create AppSync API 3. Add Lambda function(s) as Data Sources to AppSync API 4. Create API schema (GraphQL schema) 5. Attach Resolvers and edit mappings 6. Test API 7. Use API
  26. 26. AWS AppSync and the AWS landscape
  27. 27. Where does AppSync fit in AWS Serverless Short answer Nowhere (it is not part of the documented reference architecture) The real answer Wherever you see API Gateway Wherever an application needs to call an AWS back-end for something AppSync is an API Proxy that leverages GraphQL instead of REST
  28. 28. Amazon API Gateway Source: https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html
  29. 29. Examples (from AWS Serverless) Source: https://aws.amazon.com/serverless/
  30. 30. Wrap up
  31. 31. AWS AppSync (hosted GraphQL) Alternatives AWS is the only big 3 cloud vendor with a GraphQL service GraphQL servers are easily deployed to a server or a PaaS Google Firebase - deploy as a Function (performance?) Prisma Cloud For development (these are not managed services) ● https://codesandbox.io/s/apollo-server ● https://glitch.com/~apollo-launchpad
  32. 32. AWS Amplify Framework Evolution of AWS Mobile Hub Amazon's answer to Google Firebase Goal - make it easy for application (front-end) developers to use (consume) back- end resources “The foundation for your cloud-powered mobile & web apps”
  33. 33. Resources https://graphql.org https://www.graphqlweekly.com/ https://www.howtographql.com/ https://www.meetup.com/GraphQL-Toronto/ https://github.com/aws-samples (for developers)
  34. 34. Thank you! @peter_dyer fullsapps.com

×