SlideShare a Scribd company logo
© 2019, Amazon Web Services, Inc. or its Affiliates.© 2019, Amazon Web Services, Inc. or its Affiliates.
Sergey Pugachev
GraphQL backend with
AWS AppSync & AWS Lambda
Solutions Architect, AWS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fullstack
https://www.flickr.com/photos/ginnerobot/2549674908/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Backend
Front end
CI/CD
https://www.flickr.com/photos/ginnerobot/2549674908/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
Serverless means…
© 2019, Amazon Web Services, Inc. or its Affiliates.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cloud Services
Cloud
Less More
Compute Virtual Machine
EC2 Elastic Beanstalk AWS LambdaFargate
Databases MySQL MySQL on EC2
RDS MySQL RDS Aurora Aurora Serverless DynamoDB
Storage Storage
S3
Messaging ESBs
Amazon MQ Kinesis SQS / SNS
Analytics
Hadoop Hadoop on EC2 EMR Elasticsearch Service Athena
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Docker orchestration in the cloud
Management
Hosting
Amazon Elastic
Container Service
Amazon Elastic
Kubernetes Service
Amazon EC2 AWS Fargate
Image Registry Amazon Elastic
Container Registry
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Upstream Kubernetes
Use standard Kubernetes APIs.
Works with community tools.
Highly available
Built for production workloads, all clusters are highly
available. Backed by a 99.9% SLA.
Integrated
with the AWS ecosystem: VPC Networking, Elastic Load
Balancing, IAM Permissions, CloudWatch and more
Amazon Elastic Kubernetes Service
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managed by AWS
No EC2 Instances to provision, scale or manage
Elastic
Scale up & down seamlessly. Pay only for what you use
Integrated
with the AWS ecosystem: VPC Networking, Elastic Load
Balancing, IAM Permissions, CloudWatch and more. Run
Kubernetes pods or ECS tasks.
AWS Fargate
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
{API}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
InternetMobile &
web apps
Databases &
data stores
Basic API technology stack
Failover
Load balancers
Web & application servers
Message buses
Workers
?API
backend
?API
“server”
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS
InternetMobile &
web apps
Databases &
data stores
Basic API technology stack
Failover
Load balancers
Web & application servers
Message buses
Workers
?API
backend
?API
“server”
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
InternetMobile &
web apps
Basic serverless API technology stack
AWS
Serverless
business logic
Serverless
APIs
Databases &
data stores
Fail over
Load balancers
Web/application servers
Message buses
Workers
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
/posts /comments /authors
REST API
posts comments authors
GraphQL API
What is GraphQL?
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Queries MutationsTypes
Subscriptions
GraphQL schema and operations
A query language for APIs . . . and a runtime!
type User {
id: ID!
username: String!
firstName: String
lastName: String
daysActive: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Queries
query GetPost {
getPost(id: ”1”) {
id
title
}
}
mutation CreatePost {
createPost(title: “Summit”) {
id
title
}
}
subscription OnCreatePost {
onCreatePost {
id
title
}
}
Mutations Subscriptions
A query language for APIs . . .
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS AppSync
Managed serverless
GraphQL service
Connect to data
sources in your account
Add data sync, real-time, and
offline capabilities for any data
source or API
GraphQL facade for any
AWS service
Conflict detection and
resolution in the cloud
Enterprise security features:
IAM, Amazon Cognito, OIDC,
API keys
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How does AWS AppSync work?
,
,
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL data flow in AWS AppSync: Resolvers
Request template Response template
Data sources
1 2 3 4 5
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline resolvers
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Real-time data broadcasting
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Real-time subscriptions
subscription onCreateMessage {
createMessage {…}
}
WebSocket URL and connection payload
Secure WebSocket connection (wss://)
AppSync Data Sources
AWS AppSync
Amazon
DynamoDB
Amazon Elasticsearch
Service
AWS Lambda
Amazon Aurora
HTTP
Local (Pub/Sub)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Offline
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Polyglot backend data access
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amplify Framework
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amplify Framework
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amplify Framework
ü CLI
ü Client libraries (native and JS support)
ü Console – Continuous deployment
and hosting
ü Prebuilt UI components
ü Toolchain
ü JS framework support
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• Create, update, and delete cloud services
• Manage multiple environments
• GraphQL Transform
• GraphQL Codegen
Amplify Framework
CLI
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Categories
Authentication
Analytics
Interactions (chat bots)
API (REST)
API (GraphQL)
Amplify CLI
Serverless functions
Storage
XR
Push notifications
Video
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add auth
$ amplify push
$ amplify configure auth
$ amplify delete
$ amplify codegen add
Amplify CLI
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add api
–
# schema.graphql
type Post @model {
id: ID!
title: String!
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
@model
Top-level entity; creates DynamoDB table, resolvers, and additional schema (queries,
mutations, and subscriptions) for base type
@connection
Enables relationships between @model types
@auth
Enables set of authorization rules
@searchable
Handles streaming the data of an @model object type to Amazon Elasticsearch Service
and configures search resolvers
@versioned
Enables versioning
@function
Enables adding a Lambda function as a data source
–
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL Transform: Mix and match data sources
type Post {
id: ID!
content: String
description: String
ups: Int
downs: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL Transform: Mix and match data sources
createPost
readPost
updatePost
deletePost
type Post
@model {
id: ID!
content: String
description: String
ups: Int
downs: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL Transform: Mix and match data sources
mutations
queries
createPost
readPost
updatePost
deletePost
type Post
@model
@auth(rules: [{allow:
owner}]){
id: ID!
content: String
description: String
ups: Int
downs: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL Transform: Mix and match data sources
searchPosts
mutations
queries
createPost
readPost
updatePost
deletePost
type Post
@model
@auth(rules: [{allow: owner}])
@searchable{
id: ID!
content: String
description: String
ups: Int
downs: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GraphQL Transform: Mix and match data sources
searchPosts
mutations
queries
createPost
readPost
updatePost
deletePost
type Post
@model
@auth(rules: [{allow:
owner}])
@searchable{
id: ID!
content: String
description: String
ups: Int
downs: Int
}
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add codegen [--apiId <api-id>]
// Will generate GraphQL statements
// (queries, mutations, subscriptions)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify env add
$ amplify env list
$ amplify env checkout
$ amplify env remove
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multiple environments and team workflow
• Git-style interaction and project switching
• Share backends between team members or clone for sandbox isolated development
User Users
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amplify Framework
• Connect to and interact with cloud services from web and mobile
applications
• Preconfigured components for popular front-end libraries
Client
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify client
• Opinionated
• Declarative
• Client focused
• High-level abstractions
• Best practices built in
• Built with Amplify CLI in mind
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify client
import {
Auth, API, Storage, Analytics, XR
} from ‘aws-amplify’
$ npm install aws-amplify
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify client
import {
Auth
} from ‘aws-amplify’
Auth.signIn(’myusername’, ‘mypassword’)
Auth.signOut()
Auth.currentAuthenticatedUser()
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify: Native support
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify: JS framework support
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Higher-order components
import {withAuthenticator} from ‘aws-amplify-react’
export default withAuthenticator(App)
class App extends Component {
// your code goes here
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon API Gateway
Amazon Pinpoint
AWS Lambda
AWS AppSync Amazon DynamoDBAmazon Cognito
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Deploying a Lambda function with API Gateway
1. Create the Lambda function & API
$ amplify add api
// chose REST with Express backend
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2. Write code/make changes
// amplify/backend/function/<FUNCTION_NAME>/src/app.js
app.get(‘/items’, function(req, res) {
// new code goes here
})
Deploying a Lambda function with API Gateway
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify push
3. Deploy new API
Deploying a Lambda function with API Gateway
Amazon API Gateway AWS Lambda
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import { API } from ‘aws-amplify’
API.get(’/items’)
.then(data => console.log({ data }))
.catch(err => console.log({ err })
4. Interact with the API
Deploying a Lambda function with API Gateway
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add auth
// choose either default or custom configuration
1. Create the authentication service
Adding authentication
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import { Auth } from ‘aws-amplify’
2. Import the Auth component
Adding authentication
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auth.signUp(‘username’, ‘password’, {
attributes: { email: ‘jane@doe.com’ }
})
Auth.signIn(’myusername’, ‘mypassword’)
3. Implement Auth methods
Adding authentication
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add api
// chose GraphQL
1. Create the GraphQL API
Deploying a GraphQL API
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
type Todo @model {
id: ID!
name: String!
description: String!
completed: Boolean
}
2. Define annotated GraphQL schema
Deploying a GraphQL API
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify push
3. Deploy new API
Deploying a GraphQL API
Amazon Cognito AWS AppSync Amazon DynamoDB
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import { API, GraphqlOperation } from ‘aws-amplify’
import { listTodos } from ‘./src/graphql/queries’
API.graphql(graphqlOperation(listTodos))
.then(data => console.log({ data }))
.catch(err => console.log({ err })
4. Interact with API
Deploying a GraphQL API
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
$ amplify add analytics
$ amplify push
1. Create analytics service
Adding analytics
Amazon Pinpoint
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2. Import Analytics API
Adding analytics
import { Analytics } from ‘aws-amplify’
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
3. Record events
Adding analytics
Analytics.record({ name: 'albumVisit’ })
Analytics.record({
name: 'albumVisit', // Attribute values must be strings
attributes: { genre: ‘nu-metal', artist: ’RATM’ }
})
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon API Gateway
Amazon Pinpoint
AWS Lambda
AWS AppSync Amazon DynamoDBAmazon Cognito
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS AppSync JS SDK
• Offline ready
• Built-in helpers for optimistic response,
subscriptions
• Use with React Apollo / Vue Apollo /
Angular Apollo
• https://github.com/awslabs/aws-mobile-appsync-sdk-js
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fullstack DevOps for web apps
• Strong isolation barrier between projects and stages
Dedicated AWS accounts for each project and stage (sandbox, staging, prod)
• Source code (and history) for each stage readily available
Git branching used for the source code for each stage
• Minimize version mismatches between front end and backend
Front end (e.g., code) and backend (e.g., AWS CloudFormation templates)
developed and versioned together in same Git repository
• Developers in control
Developers deploy front end *and* backend
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOps requirements for modern web apps
Web app
per dev
sandbox
Test web app Prod web app
Isolated
backends
Shared backend
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOps challenges with modern web apps
Lots of moving parts complicate the following:
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Amplify Console
Build, deploy, and host cloud-powered modern web apps
Optional deployment of backend resources +
fully managed front-end hosting
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use cases
Use static site generators like Hugo or Jekyll
to publish a blog. SSGs perform faster than
traditional websites. Deploy SSGs with free
SSL on the AWS Amplify Console.
Add dynamic functionality using GraphQL or
REST APIs. Use the AWS Amplify Console to
deploy your front end and backend in a single
workflow.
PWAs offer native app-like performance, work
offline, support push notifications, and can be
updated over the air. Use AWS Amplify to
deploy PWAs to mobile devices.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its Affiliates.
Sergey Pugachev
GraphQL backend with
AWS AppSync & AWS Lambda
Solutions Architect, AWS

More Related Content

Similar to GraphQL backend with AWS AppSync & AWS Lambda (20)

PDF
AWS Stockholm Summit 19- Building serverless applications with GraphQL
Marcia Villalba
 
PDF
Simplify your Web & Mobile applications with cloud-based serverless backends
Sébastien ☁ Stormacq
 
PDF
AWS Meetup Brussels 3rd Sep 2019 Simplify Frontend Apps with Serverless Backends
Patrick Sard
 
PDF
20200520 - Como empezar a desarrollar aplicaciones serverless
Marcia Villalba
 
PDF
Rapid mobile development using GraphQL and AWS AppSync
Gabe Hollombe
 
PDF
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...
Darko Mesaroš
 
PDF
Serverless <3 GraphQL - AWS UG Tampere 2020
Marcia Villalba
 
PPTX
Introduction to AWS Amplify and the Amplify CLI Toolchain
AWS Germany
 
PDF
AppSync in real world - pitfalls, unexpected benefits & lessons learnt
AWS User Group Bengaluru
 
PDF
Full Stack Serverless 1st Edition Nader Dabit
ibokocazim
 
PDF
20200513 Getting started with AWS Amplify
Marcia Villalba
 
PDF
Full Stack Serverless 1st Edition Nader Dabit
gwapateyei
 
PDF
AWS Summit Singapore 2019 | AWS Techfest Opening Keynote
AWS Summits
 
PDF
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
Codemotion
 
PPTX
Serverless GraphQL. AppSync 101
Marcin Sodkiewicz
 
PDF
Serverless applications with AWS
javier ramirez
 
PDF
API moderne e real-time per applicazioni innovative
Commit University
 
PPTX
AWS Startup Garage - Building your MVP on AWS
Cobus Bernard
 
PDF
AWS Startup Day Bogotá - Tools for Building Your Startup
Amazon Web Services LATAM
 
PPTX
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Amazon Web Services LATAM
 
AWS Stockholm Summit 19- Building serverless applications with GraphQL
Marcia Villalba
 
Simplify your Web & Mobile applications with cloud-based serverless backends
Sébastien ☁ Stormacq
 
AWS Meetup Brussels 3rd Sep 2019 Simplify Frontend Apps with Serverless Backends
Patrick Sard
 
20200520 - Como empezar a desarrollar aplicaciones serverless
Marcia Villalba
 
Rapid mobile development using GraphQL and AWS AppSync
Gabe Hollombe
 
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...
Darko Mesaroš
 
Serverless <3 GraphQL - AWS UG Tampere 2020
Marcia Villalba
 
Introduction to AWS Amplify and the Amplify CLI Toolchain
AWS Germany
 
AppSync in real world - pitfalls, unexpected benefits & lessons learnt
AWS User Group Bengaluru
 
Full Stack Serverless 1st Edition Nader Dabit
ibokocazim
 
20200513 Getting started with AWS Amplify
Marcia Villalba
 
Full Stack Serverless 1st Edition Nader Dabit
gwapateyei
 
AWS Summit Singapore 2019 | AWS Techfest Opening Keynote
AWS Summits
 
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
Codemotion
 
Serverless GraphQL. AppSync 101
Marcin Sodkiewicz
 
Serverless applications with AWS
javier ramirez
 
API moderne e real-time per applicazioni innovative
Commit University
 
AWS Startup Garage - Building your MVP on AWS
Cobus Bernard
 
AWS Startup Day Bogotá - Tools for Building Your Startup
Amazon Web Services LATAM
 
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Amazon Web Services LATAM
 

More from Aleksandr Maklakov (14)

PPTX
AWS Certification from scratch
Aleksandr Maklakov
 
PPTX
Chronicle of ReInvent 2019
Aleksandr Maklakov
 
PDF
How to stop dreaming about security and start implementing
Aleksandr Maklakov
 
PPTX
Secure perimeter with AWS workspaces
Aleksandr Maklakov
 
PPTX
Going Serverless on AWS
Aleksandr Maklakov
 
PDF
AWS Security Best Practices
Aleksandr Maklakov
 
PDF
AWS Container services
Aleksandr Maklakov
 
PPTX
How to implement DevSecOps on AWS for startups
Aleksandr Maklakov
 
PDF
AWS CloudFront
Aleksandr Maklakov
 
PDF
HOW TO DRONE.IO IN CI/CD WORLD
Aleksandr Maklakov
 
PDF
Amazon EC2 container service
Aleksandr Maklakov
 
PDF
Continuous operations in AWS
Aleksandr Maklakov
 
PDF
Architecture of NoSQL distributed clusters on AWS
Aleksandr Maklakov
 
PDF
Managing users and aws accounts
Aleksandr Maklakov
 
AWS Certification from scratch
Aleksandr Maklakov
 
Chronicle of ReInvent 2019
Aleksandr Maklakov
 
How to stop dreaming about security and start implementing
Aleksandr Maklakov
 
Secure perimeter with AWS workspaces
Aleksandr Maklakov
 
Going Serverless on AWS
Aleksandr Maklakov
 
AWS Security Best Practices
Aleksandr Maklakov
 
AWS Container services
Aleksandr Maklakov
 
How to implement DevSecOps on AWS for startups
Aleksandr Maklakov
 
AWS CloudFront
Aleksandr Maklakov
 
HOW TO DRONE.IO IN CI/CD WORLD
Aleksandr Maklakov
 
Amazon EC2 container service
Aleksandr Maklakov
 
Continuous operations in AWS
Aleksandr Maklakov
 
Architecture of NoSQL distributed clusters on AWS
Aleksandr Maklakov
 
Managing users and aws accounts
Aleksandr Maklakov
 
Ad

Recently uploaded (20)

PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Python basic programing language for automation
DanialHabibi2
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ad

GraphQL backend with AWS AppSync & AWS Lambda

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates.© 2019, Amazon Web Services, Inc. or its Affiliates. Sergey Pugachev GraphQL backend with AWS AppSync & AWS Lambda Solutions Architect, AWS
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Fullstack https://www.flickr.com/photos/ginnerobot/2549674908/
  • 3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Backend Front end CI/CD https://www.flickr.com/photos/ginnerobot/2549674908/
  • 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Serverless means…
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates.
  • 6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cloud Services Cloud Less More Compute Virtual Machine EC2 Elastic Beanstalk AWS LambdaFargate Databases MySQL MySQL on EC2 RDS MySQL RDS Aurora Aurora Serverless DynamoDB Storage Storage S3 Messaging ESBs Amazon MQ Kinesis SQS / SNS Analytics Hadoop Hadoop on EC2 EMR Elasticsearch Service Athena
  • 7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Docker orchestration in the cloud Management Hosting Amazon Elastic Container Service Amazon Elastic Kubernetes Service Amazon EC2 AWS Fargate Image Registry Amazon Elastic Container Registry
  • 8. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Upstream Kubernetes Use standard Kubernetes APIs. Works with community tools. Highly available Built for production workloads, all clusters are highly available. Backed by a 99.9% SLA. Integrated with the AWS ecosystem: VPC Networking, Elastic Load Balancing, IAM Permissions, CloudWatch and more Amazon Elastic Kubernetes Service
  • 9. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Managed by AWS No EC2 Instances to provision, scale or manage Elastic Scale up & down seamlessly. Pay only for what you use Integrated with the AWS ecosystem: VPC Networking, Elastic Load Balancing, IAM Permissions, CloudWatch and more. Run Kubernetes pods or ECS tasks. AWS Fargate
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. {API}
  • 12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. InternetMobile & web apps Databases & data stores Basic API technology stack Failover Load balancers Web & application servers Message buses Workers ?API backend ?API “server”
  • 13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS InternetMobile & web apps Databases & data stores Basic API technology stack Failover Load balancers Web & application servers Message buses Workers ?API backend ?API “server”
  • 14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. InternetMobile & web apps Basic serverless API technology stack AWS Serverless business logic Serverless APIs Databases & data stores Fail over Load balancers Web/application servers Message buses Workers
  • 15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. /posts /comments /authors REST API posts comments authors GraphQL API What is GraphQL?
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Queries MutationsTypes Subscriptions GraphQL schema and operations A query language for APIs . . . and a runtime! type User { id: ID! username: String! firstName: String lastName: String daysActive: Int }
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Queries query GetPost { getPost(id: ”1”) { id title } } mutation CreatePost { createPost(title: “Summit”) { id title } } subscription OnCreatePost { onCreatePost { id title } } Mutations Subscriptions A query language for APIs . . .
  • 18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS AppSync Managed serverless GraphQL service Connect to data sources in your account Add data sync, real-time, and offline capabilities for any data source or API GraphQL facade for any AWS service Conflict detection and resolution in the cloud Enterprise security features: IAM, Amazon Cognito, OIDC, API keys
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. How does AWS AppSync work? , ,
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL data flow in AWS AppSync: Resolvers Request template Response template Data sources 1 2 3 4 5
  • 23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline resolvers
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Real-time data broadcasting
  • 25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Real-time subscriptions subscription onCreateMessage { createMessage {…} } WebSocket URL and connection payload Secure WebSocket connection (wss://) AppSync Data Sources AWS AppSync Amazon DynamoDB Amazon Elasticsearch Service AWS Lambda Amazon Aurora HTTP Local (Pub/Sub)
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Offline
  • 27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Polyglot backend data access
  • 28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amplify Framework
  • 30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amplify Framework
  • 31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amplify Framework ü CLI ü Client libraries (native and JS support) ü Console – Continuous deployment and hosting ü Prebuilt UI components ü Toolchain ü JS framework support
  • 32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Create, update, and delete cloud services • Manage multiple environments • GraphQL Transform • GraphQL Codegen Amplify Framework CLI
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Categories Authentication Analytics Interactions (chat bots) API (REST) API (GraphQL) Amplify CLI Serverless functions Storage XR Push notifications Video
  • 34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add auth $ amplify push $ amplify configure auth $ amplify delete $ amplify codegen add Amplify CLI
  • 35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add api – # schema.graphql type Post @model { id: ID! title: String! }
  • 36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. @model Top-level entity; creates DynamoDB table, resolvers, and additional schema (queries, mutations, and subscriptions) for base type @connection Enables relationships between @model types @auth Enables set of authorization rules @searchable Handles streaming the data of an @model object type to Amazon Elasticsearch Service and configures search resolvers @versioned Enables versioning @function Enables adding a Lambda function as a data source –
  • 37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL Transform: Mix and match data sources type Post { id: ID! content: String description: String ups: Int downs: Int }
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL Transform: Mix and match data sources createPost readPost updatePost deletePost type Post @model { id: ID! content: String description: String ups: Int downs: Int }
  • 39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL Transform: Mix and match data sources mutations queries createPost readPost updatePost deletePost type Post @model @auth(rules: [{allow: owner}]){ id: ID! content: String description: String ups: Int downs: Int }
  • 40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL Transform: Mix and match data sources searchPosts mutations queries createPost readPost updatePost deletePost type Post @model @auth(rules: [{allow: owner}]) @searchable{ id: ID! content: String description: String ups: Int downs: Int }
  • 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraphQL Transform: Mix and match data sources searchPosts mutations queries createPost readPost updatePost deletePost type Post @model @auth(rules: [{allow: owner}]) @searchable{ id: ID! content: String description: String ups: Int downs: Int }
  • 42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add codegen [--apiId <api-id>] // Will generate GraphQL statements // (queries, mutations, subscriptions)
  • 43. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify env add $ amplify env list $ amplify env checkout $ amplify env remove
  • 44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multiple environments and team workflow • Git-style interaction and project switching • Share backends between team members or clone for sandbox isolated development User Users
  • 45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amplify Framework • Connect to and interact with cloud services from web and mobile applications • Preconfigured components for popular front-end libraries Client
  • 46. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify client • Opinionated • Declarative • Client focused • High-level abstractions • Best practices built in • Built with Amplify CLI in mind
  • 47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify client import { Auth, API, Storage, Analytics, XR } from ‘aws-amplify’ $ npm install aws-amplify
  • 48. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify client import { Auth } from ‘aws-amplify’ Auth.signIn(’myusername’, ‘mypassword’) Auth.signOut() Auth.currentAuthenticatedUser()
  • 49. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify: Native support
  • 50. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify: JS framework support
  • 51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Higher-order components import {withAuthenticator} from ‘aws-amplify-react’ export default withAuthenticator(App) class App extends Component { // your code goes here
  • 52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon API Gateway Amazon Pinpoint AWS Lambda AWS AppSync Amazon DynamoDBAmazon Cognito
  • 53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Deploying a Lambda function with API Gateway 1. Create the Lambda function & API $ amplify add api // chose REST with Express backend
  • 54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2. Write code/make changes // amplify/backend/function/<FUNCTION_NAME>/src/app.js app.get(‘/items’, function(req, res) { // new code goes here }) Deploying a Lambda function with API Gateway
  • 55. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify push 3. Deploy new API Deploying a Lambda function with API Gateway Amazon API Gateway AWS Lambda
  • 56. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import { API } from ‘aws-amplify’ API.get(’/items’) .then(data => console.log({ data })) .catch(err => console.log({ err }) 4. Interact with the API Deploying a Lambda function with API Gateway
  • 57. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add auth // choose either default or custom configuration 1. Create the authentication service Adding authentication
  • 58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import { Auth } from ‘aws-amplify’ 2. Import the Auth component Adding authentication
  • 59. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Auth.signUp(‘username’, ‘password’, { attributes: { email: ‘[email protected]’ } }) Auth.signIn(’myusername’, ‘mypassword’) 3. Implement Auth methods Adding authentication
  • 60. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add api // chose GraphQL 1. Create the GraphQL API Deploying a GraphQL API
  • 61. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. type Todo @model { id: ID! name: String! description: String! completed: Boolean } 2. Define annotated GraphQL schema Deploying a GraphQL API
  • 62. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify push 3. Deploy new API Deploying a GraphQL API Amazon Cognito AWS AppSync Amazon DynamoDB
  • 63. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import { API, GraphqlOperation } from ‘aws-amplify’ import { listTodos } from ‘./src/graphql/queries’ API.graphql(graphqlOperation(listTodos)) .then(data => console.log({ data })) .catch(err => console.log({ err }) 4. Interact with API Deploying a GraphQL API
  • 64. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. $ amplify add analytics $ amplify push 1. Create analytics service Adding analytics Amazon Pinpoint
  • 65. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2. Import Analytics API Adding analytics import { Analytics } from ‘aws-amplify’
  • 66. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. 3. Record events Adding analytics Analytics.record({ name: 'albumVisit’ }) Analytics.record({ name: 'albumVisit', // Attribute values must be strings attributes: { genre: ‘nu-metal', artist: ’RATM’ } })
  • 67. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon API Gateway Amazon Pinpoint AWS Lambda AWS AppSync Amazon DynamoDBAmazon Cognito
  • 68. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS AppSync JS SDK • Offline ready • Built-in helpers for optimistic response, subscriptions • Use with React Apollo / Vue Apollo / Angular Apollo • https://github.com/awslabs/aws-mobile-appsync-sdk-js
  • 69. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 70. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 71. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Fullstack DevOps for web apps • Strong isolation barrier between projects and stages Dedicated AWS accounts for each project and stage (sandbox, staging, prod) • Source code (and history) for each stage readily available Git branching used for the source code for each stage • Minimize version mismatches between front end and backend Front end (e.g., code) and backend (e.g., AWS CloudFormation templates) developed and versioned together in same Git repository • Developers in control Developers deploy front end *and* backend
  • 72. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. DevOps requirements for modern web apps Web app per dev sandbox Test web app Prod web app Isolated backends Shared backend
  • 73. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. DevOps challenges with modern web apps Lots of moving parts complicate the following:
  • 74. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Amplify Console Build, deploy, and host cloud-powered modern web apps Optional deployment of backend resources + fully managed front-end hosting
  • 75. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Use cases Use static site generators like Hugo or Jekyll to publish a blog. SSGs perform faster than traditional websites. Deploy SSGs with free SSL on the AWS Amplify Console. Add dynamic functionality using GraphQL or REST APIs. Use the AWS Amplify Console to deploy your front end and backend in a single workflow. PWAs offer native app-like performance, work offline, support push notifications, and can be updated over the air. Use AWS Amplify to deploy PWAs to mobile devices.
  • 76. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its Affiliates. Sergey Pugachev GraphQL backend with AWS AppSync & AWS Lambda Solutions Architect, AWS