Running Serverless Realtime GraphQL Applications With AppSync

Running Serverless Realtime GraphQL Applications With AppSync

About the Book

This is a book for developers, architects and technology leaders who want to learn about the latest generation of cloud technologies and how to build highly scalable, responsive web sites and APIs.

About the Authors

Gojko Adzic
Gojko Adzic

Gojko Adzic is a partner at Neuri Consulting LLP. He He one of the 2019 AWS Serverless Heroes, the winner of the 2016 European Software Testing Outstanding Achievement Award, and the 2011 Agile Testing Days Most Influential Professional award. Gojko's book Specification by Example won the Jolt Award for the best book of 2012, and his blog won the UK Agile Award for the best online publication in 2010.

Gojko is a frequent keynote speaker at leading software development conferences, and one of the authors of Narakeet and MindMup. As a consultant, Gojko helped companies around the world improve software delivery, from some of the largest financial institutions to small innovative startups.

To get in touch, write to gojko@neuri.com or visit http://gojko.net

Slobodan Stojanović
Slobodan Stojanović

Slobodan Stojanović is CTO of Cloud Horizon, a software development studio based in Montreal Canada, and CTO of Vacation Tracker, a simple Slack-based leave management system for teams. He is based in Belgrade and is the JS Belgrade meetup co-organizer.

Slobodan is the AWS Serverless HeroClaudia.js core team member, and co-author of the “Serverless Applications with Node.js” book, published by Manning Publications.

Table of Contents

  • Introduction

  • Here is what we’re going to build

    • Quick domain intro
    • Upollo architecture:
  • Appsync in five minutes

    • What is AppSync?
    • When to use AppSync?
    • When not to use AppSync?
    • Why GraphQL?
    • How AppSync works with other AWS services?
  • CDK in five minutes

    • Infrastructure as code – literally
    • Why CDK?
    • CDK constructs
    • How CDK compares to other deployment tools
    • Setting up CDK for local development
    • Setting up your AWS account
    • Testing the configuration
  • Part 1: Basic Development tasks

    • Your first AppSync app

      • Hello World from CDK and AppSync
      • Deploying an AppSync App
      • AppSync application structure
      • Generating API Keys
      • Retrieving CloudFormation outputs with CDK
      • Trying it out from the AWS console
      • Trying it out from the command line
      • Troubleshooting Appsync
      • Accessing Data Sources from AppSync
      • What are AppSync Resolvers?
      • Troubleshooting deployments
      • How to remove deployed applications
      • Other Authentication options
      • Where to find more information?
    • Building a simple GraphQL Schema

      • Modelling GraphQl Types
      • Modelling GraphqQL operations
      • Verifying your schema
      • VTL template basics
      • Passing arguments using AppSync VTL context
      • Formatting results using AppSync VTL utility functions
    • Testing AppSync applications

      • Simulating AppSync for local tests
      • Automated integration-testing with AppSync
      • Securing access using IAM
      • Testing API access
      • Unit testing VTL templates
  • Part 2: Working with persistent data

    • Connecting AppSync to DynamoDB

      • Why DynamoDB?
      • Adding a database using CDK
      • Accessing DynamoDB items using the web console
      • Accessing DynamoDB records from the command line
      • Reading from DynamoDB via AppSync: getSurveyById
      • VTL templates for DynamoDB
      • Integration testing AppSync with DynamoDb
    • Working with Mutations

      • Scope for this chapter
      • Saving to DynamoDB using AppSync: createSurvey
      • Creating unique IDs in resolvers using util.autoId
      • Updating existing Dynamo records
      • Using update conditionals to preventing accidental object creation
    • Single-table dynamo design

      • How Dynamo tables compare to SQL tables
      • Why single tables?
      • Modelling relations with single-table design
      • Example Upollo records
      • Migrating resolvers to single-table design: saving answers with createSurvey
      • Using Dynamo batch writes for performance
    • Accessing object graphs with GraphQL

      • Using DynamoDB queries to list collections by prefix
      • Accessing object graphs using GraphQl subitem queries
      • Adding answers to getSurveyById
      • Queries for lists: getAnswersBySurveyId
      • Using pipeline resolvers to customise output
      • Sharing VTL templates between resolvers: how to read ID from stash or args with util.defaultIfNull
      • Testing hierarchical resolvers
    • Performing complex updates

      • Atomically updating Dynamo item fields
      • Using DynamoDB transaction writes for consistency
      • Processing votes: addVote
      • Capturing timestamps using $util.time.nowISO8601
  • Part 3: Working with web clients

    • Introduction to AWS Amplify

      • Using the aws-amplify React Client
      • Creating and deploying an Amplify App that connects to AppSync
      • Running graphQL queries
      • Executing GraphQl mutations
    • Authenticating users with AWS Cognito

      • What is Cognito?
      • User pools
      • Hosted UI
      • Allowing Cognito access in GraphQL
      • Testing Cognito access from the AWS Web console
      • Integrating Cognito with Amplify Apps
      • Modelling data security using GraphQl
      • Restricting data reads using AppSync
      • Dealing with unauthorised access on the front end
    • Realtime updates with GraphQl subscriptions

      • How GraphQl subscriptions work?
      • Declaring Subscriptions in the schema
      • Triggering subscriptions with mutations
      • Subscribing to updates using Amplify SDK
  • Part 4: Connecting to other services using AppSync Resolvers

    • Using AWS Lambda for custom processing

      • Converting data using Lambda
      • Connecting to other AWS Services (S3)
      • Using Lambda logs for CloudWatch metrics
    • Searching using ElasticSearch/OpenSearch

      • Updating ElasticSearch documents using DynamoDB streams
    • Connecting to external APIs using HTTP resolvers
    • Processing transient data with local resolvers
      • Triggering custom notifications
  • Part 5: Operating AppSync applications

    • Working with deployment pipelines

      • Setting up for teamwork
      • Deploying CDK apps using AWS CodePipeline
      • Deploying AWS Amplify Apps
      • Managing dev, test, staging and production stacks
      • Configuring using SSM
    • Monitoring AppSync applications

      • ClodudWatch logs
      • CloudWatch insights
      • Adding custom metrics
      • XRay
    • Setting up a custom domain

      • Integrating AppSync APIs with CloudFront distributions
      • Deploying to multiple regions
  • Part 6: Quick reference guide

    • GraphQL reference

      • Types
      • Mutations
      • Queries
      • Subscriptions
      • AppSync extensions
    • VTL reference

      • What is VTL?
      • Conditions
      • Loops
      • AppSync context
      • AppSync Utility functions

Authors have earned$10,327,236writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub