SlideShare a Scribd company logo
1 of 28
Download to read offline
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kwun-Hok Chan, Solution Architect
khchan@amazon.com
Building Real-time and Offline Applications
AWS AppSync
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GET /about/me
{
"name": "Kwun-Hok Chan",
"email": "khchan@amazon.com",
"company": "Amazon Web Services",
"title": "Solution Architect",
”location": ”Hong Kong",
"aod": [
"Serverless",
"Containers",
"DevOps”
]
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• Overview
• AWS AppSync
• GraphQL
• Demo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Overview
AWS AppSync
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync
• Build real-time,
collaborative mobile and
web apps
• Handles offline scenarios
common to mobile apps
• Automatically resolves
data conflicts
• Quickly prototype and
build apps from multiple
data sources
• Fully-managed GraphQL
service with benefits
• Helps keep data secure
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What problem does it solve?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Developer Challenges With App Data
Data requirements
vary across
devices and
become harder
when multiple
users share data
Users want instant
access to data
Building scalable
data-driven apps
without learning
distributed
systems concepts
is hard
Users want to
continue using
their apps even
with low or no
connectivity
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Build Powerful Data Driven Apps With AppSync
Real-time
Collaboration
Offline
Programming
Model with
Sync
Get Only the
Data You Need
Own Your Data Fine-grained
Access
Control
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Apps You Can Build With AppSync
Real-time Apps
- Dashboard
- Leaderboard
- Field service apps
Chat Apps Apps with Complex
Data Structures
and Types
Geo Apps
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does AWS AppSync work?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Let’s simplify by comparing with a
more well-understood approach
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
I have a web and mobile app, and a data source
Data
API Gateway Lambda
Using API Gateway and Lambda is one
approach for performing DB operations
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is GraphQL?
Open, declarative data-fetching specification
!= Graph database
Use NoSQL, Relational, HTTP, etc.
Traditional data-fetching GraphQL
/posts
/postInfo
/postJustTitle
/postsByAuthor
/postNameStartsWithX
/commentsOnPost
/graphql
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does GraphQL work?
{
"id": "1",
"name": "Get Milk",
“priority": "1"
},
{
"id": “2",
"name": “Go to gym",
“priority": “5"
},…
type Query {
getTodos: [Todo]
}
type Todo {
id: ID!
name: String
description: String
priority: Int
duedate: String
}
query {
getTodos {
id
name
priority
}
}
Model data with
application schema
Client requests what it
needs
Only that data is
returned
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Subscriptions
Near Realtime updates of data
Event based mode, triggered by Mutations
- Scalable model, designed as a platform for common use-cases
Can be used with ANY data source in AppSync
- Lambda, DynamoDB, Elasticsearch
mutation addPost( id:123
title:”New post!”
author:”Nadia”){
id
title
author
}
data: [{
id:123,
title:”New Post!”
author:”Nadia”
}]
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
type Subscription {
addedPost: Post
@aws_subscribe(mutations: ["addPost"])
deletedPost: Post
@aws_subscribe(mutations: ["deletePost"])
}
type Mutation {
addPost(id: ID! author: String! title:
String content: String): Post!
deletePost(id: ID!): Post!
}
subscription NewPostSub {
addedPost {
__typename
version
title
content
author
url
}
}
Schema
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Subscription Handshake
Subscription NewPostSub {
addedPost{…}
}
WebSocket URL and Connection Payload
Secure Websocket Connection (wss://)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Real time UI updates
const AllPostsWithData = compose(
graphql(AllPostsQuery, { options: { fetchPolicy: 'cache-and-network‘ },
props: (props) => ({
posts: props.data.posts,
subscribeToNewPosts: params => {
props.data.subscribeToMore({
document: NewPostsSubscription,
updateQuery: (prev, { subscriptionData: { newPost } }) => ({
...prev,
posts: [newPost, ...prev.posts.filter(post => post.id !== newPost.id)]
})
});
});
…//more code
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Offline mutations
Jane
Version : 2 Updated Document
Jane
Version : 2 Updated Document
Version : 3 Updated Document
Version : 1 New Document
Time
John
John
Jane goes offline
Jane comes back online
Version : 4 Updated Document
John
Jane
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Conflict Resolution and Synchronization
Conflict resolution in the cloud
1. Server wins
2. Silent reject
3. Custom logic (AWS Lambda)
- Optimistic version check
- Extend with your own checks
Optional
• Client callback for Conflict Resolution is still
available as a fallback
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
"id" : { "S" : "1" }
},
"condition" : {
"expression" : "attribute_not_exists(id)"
}
}
Example: Check that an ID doesn’t already exist:
"condition" : {
"expression" : "someExpression"
"conditionalCheckFailedHandler" : {
"strategy" : "Custom",
"lambdaArn" : "arn:..."
}
}
Run Lambda if version wrong:
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Images and rich content
type S3Object {
bucket: String!
key: String!
region: String!
}
input S3ObjectInput {
bucket: String!
key: String!
region: String!
localUri: String!
}
type Profile {
name: String!
profilePic: S3Object!
}
type Mutation {
updatePhoto(name: String!,
profilePicInput: S3ObjectInput!): Profile
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Client experience and configuration
Offline is a write-through “Store”
- Persistent storage mediums back the client “normalized
cache”
- Local Storage for web
- SQLite on hybrid/native platforms
SQLite database can be preloaded
- Hydrate after installing from AppStore
Offline client can be configured
- Wifi only vs. wifi & carrier
Queries automatically persist offline
Mutations are an “optimistic write”
- Control offline UI updates with “optimistic response”
- Update views/lists when editing/adding data offline
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service Cost per month
• Free Tier lasts for first 12 months
• Don’t forget to add Data Transfer + Database
• Always review the AWS Pricing Page for latest pricing
Free Tier Standard Cost
Queries 250,000 $4 / million
Real-time Updates 250,000 $2 / million
Real-time Connection-minutes 600,000 $0.08 / million
* US Pricing, as of December 1, 2017
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pricing Example (all numbers per month)
• Chat application with 2,500 users
• Average user connects for 1,500 minutes
• Sends 1,000 and Receives 1,000 messages
• 2.5M queries and 2.5M real-time updates
AppSync Query 2.5M x $4/million = $10.00
AppSync Real-time 2.5M x $2/million = $5.00
AppSync Minutes 2,500 x 1,500 x $0.08/million = $0.30
Data Transfer 1KB x 2.5M = 2.4GB x $0.09 = $0.21
DynamoDB Database Free Tier (as long as store < 25Gb)
Total $15.51
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Happy coding with AppSync!
AWS AppSync
Amazon
DynamoDB
AWS
Lambda
ElasticSearch
subscriptions
/graphql
Resolvers
DataSources
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
We need your feedback
https://bit.ly/2HlWoST
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You!
Kwun-Hok Chan (khchan@amazon.com)

More Related Content

What's hot

How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...
How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...
How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...Amazon Web Services
 
Building Manageable Windows Workloads - ARC324 - re:Invent 2017
Building Manageable Windows Workloads - ARC324 - re:Invent 2017Building Manageable Windows Workloads - ARC324 - re:Invent 2017
Building Manageable Windows Workloads - ARC324 - re:Invent 2017Amazon Web Services
 
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Amazon Web Services
 
Building your First GraphQL API with AWS AppSync
Building your First GraphQL API with AWS AppSyncBuilding your First GraphQL API with AWS AppSync
Building your First GraphQL API with AWS AppSyncAmazon Web Services
 
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDBSRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDBAmazon Web Services
 
ABD315_Serverless ETL with AWS Glue
ABD315_Serverless ETL with AWS GlueABD315_Serverless ETL with AWS Glue
ABD315_Serverless ETL with AWS GlueAmazon Web Services
 
Testing Your App Before Launch: An Introduction to AWS Device Farm
Testing Your App Before Launch: An Introduction to AWS Device FarmTesting Your App Before Launch: An Introduction to AWS Device Farm
Testing Your App Before Launch: An Introduction to AWS Device FarmAmazon Web Services
 
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...Amazon Web Services
 
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...Amazon Web Services
 
AWS Webinar CZSK Uvod do cloud computingu
AWS Webinar CZSK Uvod do cloud computinguAWS Webinar CZSK Uvod do cloud computingu
AWS Webinar CZSK Uvod do cloud computinguVladimir Simek
 
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex Pollexy
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex PollexyMCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex Pollexy
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex PollexyAmazon Web Services
 
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...Amazon Web Services
 
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon Polly
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon PollyMCL206-Creating Next Generation Speech-Enabled Applications with Amazon Polly
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon PollyAmazon Web Services
 
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...Amazon Web Services
 
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...Amazon Web Services
 
Building Data Driven Apps with AWS
Building Data Driven Apps with AWSBuilding Data Driven Apps with AWS
Building Data Driven Apps with AWSAmazon Web Services
 
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014Amazon Web Services
 
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...Natural Language Processing Plus Natural Language Generation: The Cutting Edg...
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...Amazon Web Services
 
IOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoTIOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoTAmazon Web Services
 
Building Data Driven Apps with AWS: Collision 2018
Building Data Driven Apps with AWS: Collision 2018Building Data Driven Apps with AWS: Collision 2018
Building Data Driven Apps with AWS: Collision 2018Amazon Web Services
 

What's hot (20)

How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...
How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...
How Netflix Monitors Applications in Near Real-time w Amazon Kinesis - ABD401...
 
Building Manageable Windows Workloads - ARC324 - re:Invent 2017
Building Manageable Windows Workloads - ARC324 - re:Invent 2017Building Manageable Windows Workloads - ARC324 - re:Invent 2017
Building Manageable Windows Workloads - ARC324 - re:Invent 2017
 
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
 
Building your First GraphQL API with AWS AppSync
Building your First GraphQL API with AWS AppSyncBuilding your First GraphQL API with AWS AppSync
Building your First GraphQL API with AWS AppSync
 
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDBSRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
 
ABD315_Serverless ETL with AWS Glue
ABD315_Serverless ETL with AWS GlueABD315_Serverless ETL with AWS Glue
ABD315_Serverless ETL with AWS Glue
 
Testing Your App Before Launch: An Introduction to AWS Device Farm
Testing Your App Before Launch: An Introduction to AWS Device FarmTesting Your App Before Launch: An Introduction to AWS Device Farm
Testing Your App Before Launch: An Introduction to AWS Device Farm
 
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...
User Based Multi Channel Engagement using Amazon Pinpoint and Amazon Cognito ...
 
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...
ABD302_Real-Time Data Exploration and Analytics with Amazon Elasticsearch Ser...
 
AWS Webinar CZSK Uvod do cloud computingu
AWS Webinar CZSK Uvod do cloud computinguAWS Webinar CZSK Uvod do cloud computingu
AWS Webinar CZSK Uvod do cloud computingu
 
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex Pollexy
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex PollexyMCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex Pollexy
MCL331_Building a Virtual Assistant with Amazon Polly and Amazon Lex Pollexy
 
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...
ABD214_Real-time User Insights for Mobile and Web Applications with Amazon Pi...
 
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon Polly
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon PollyMCL206-Creating Next Generation Speech-Enabled Applications with Amazon Polly
MCL206-Creating Next Generation Speech-Enabled Applications with Amazon Polly
 
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...
RET303_Drive Warehouse Efficiencies with the Same AWS IoT Technology that Pow...
 
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...
Easy and Scalable Log Analytics with Amazon Elasticsearch Service - ABD326 - ...
 
Building Data Driven Apps with AWS
Building Data Driven Apps with AWSBuilding Data Driven Apps with AWS
Building Data Driven Apps with AWS
 
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014
(SOV209) Introducing AWS Directory Service | AWS re:Invent 2014
 
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...Natural Language Processing Plus Natural Language Generation: The Cutting Edg...
Natural Language Processing Plus Natural Language Generation: The Cutting Edg...
 
IOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoTIOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoT
 
Building Data Driven Apps with AWS: Collision 2018
Building Data Driven Apps with AWS: Collision 2018Building Data Driven Apps with AWS: Collision 2018
Building Data Driven Apps with AWS: Collision 2018
 

Similar to Real Time and Offline Applications with GraphQL

NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...Amazon Web Services
 
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...Amazon Web Services
 
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAmazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
Serverless in Action on AWS
Serverless in Action on AWSServerless in Action on AWS
Serverless in Action on AWSAdrian Hornsby
 
Reactive Architectures with Microservices
Reactive Architectures with MicroservicesReactive Architectures with Microservices
Reactive Architectures with MicroservicesAWS Germany
 
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...Amazon Web Services
 
MBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldMBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldAmazon Web Services
 
Journey Towards Scaling Your API to 10 Million Users
Journey Towards Scaling Your API to 10 Million UsersJourney Towards Scaling Your API to 10 Million Users
Journey Towards Scaling Your API to 10 Million UsersAdrian Hornsby
 
CON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSCON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSAmazon Web Services
 
Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018AWS Germany
 
What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017Amazon Web Services
 
ABD317_Building Your First Big Data Application on AWS - ABD317
ABD317_Building Your First Big Data Application on AWS - ABD317ABD317_Building Your First Big Data Application on AWS - ABD317
ABD317_Building Your First Big Data Application on AWS - ABD317Amazon Web Services
 
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...Amazon Web Services
 
10 Lessons from 10 Years of AWS
10 Lessons from 10 Years of AWS10 Lessons from 10 Years of AWS
10 Lessons from 10 Years of AWSAdrian Hornsby
 
Introduction to the Serverless Cloud
Introduction to the Serverless CloudIntroduction to the Serverless Cloud
Introduction to the Serverless CloudAmazon Web Services
 

Similar to Real Time and Offline Applications with GraphQL (20)

NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
 
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
NEW LAUNCH! Realtime and Offline application development using GraphQL with A...
 
React Native Workshop
React Native WorkshopReact Native Workshop
React Native Workshop
 
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
 
Serverless Developer Experience
Serverless Developer ExperienceServerless Developer Experience
Serverless Developer Experience
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Serverless in Action on AWS
Serverless in Action on AWSServerless in Action on AWS
Serverless in Action on AWS
 
Serverless - State of the Union
Serverless - State of the UnionServerless - State of the Union
Serverless - State of the Union
 
Reactive Architectures with Microservices
Reactive Architectures with MicroservicesReactive Architectures with Microservices
Reactive Architectures with Microservices
 
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...
End-User Computing on AWS with Amazon WorkSpaces and Amazon AppStream 2.0 - E...
 
MBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldMBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real World
 
Journey Towards Scaling Your API to 10 Million Users
Journey Towards Scaling Your API to 10 Million UsersJourney Towards Scaling Your API to 10 Million Users
Journey Towards Scaling Your API to 10 Million Users
 
CON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSCON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWS
 
Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018
 
What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017
 
ABD317_Building Your First Big Data Application on AWS - ABD317
ABD317_Building Your First Big Data Application on AWS - ABD317ABD317_Building Your First Big Data Application on AWS - ABD317
ABD317_Building Your First Big Data Application on AWS - ABD317
 
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...
NEW LAUNCH! Data Driven Apps with GraphQL: AWS AppSync Deep Dive - MBL402 - r...
 
10 Lessons from 10 Years of AWS
10 Lessons from 10 Years of AWS10 Lessons from 10 Years of AWS
10 Lessons from 10 Years of AWS
 
Introduction to the Serverless Cloud
Introduction to the Serverless CloudIntroduction to the Serverless Cloud
Introduction to the Serverless Cloud
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Real Time and Offline Applications with GraphQL

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kwun-Hok Chan, Solution Architect khchan@amazon.com Building Real-time and Offline Applications AWS AppSync
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GET /about/me { "name": "Kwun-Hok Chan", "email": "khchan@amazon.com", "company": "Amazon Web Services", "title": "Solution Architect", ”location": ”Hong Kong", "aod": [ "Serverless", "Containers", "DevOps” ] }
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda • Overview • AWS AppSync • GraphQL • Demo
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Overview AWS AppSync
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync • Build real-time, collaborative mobile and web apps • Handles offline scenarios common to mobile apps • Automatically resolves data conflicts • Quickly prototype and build apps from multiple data sources • Fully-managed GraphQL service with benefits • Helps keep data secure
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What problem does it solve?
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Developer Challenges With App Data Data requirements vary across devices and become harder when multiple users share data Users want instant access to data Building scalable data-driven apps without learning distributed systems concepts is hard Users want to continue using their apps even with low or no connectivity
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Build Powerful Data Driven Apps With AppSync Real-time Collaboration Offline Programming Model with Sync Get Only the Data You Need Own Your Data Fine-grained Access Control
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Apps You Can Build With AppSync Real-time Apps - Dashboard - Leaderboard - Field service apps Chat Apps Apps with Complex Data Structures and Types Geo Apps
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does AWS AppSync work?
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Let’s simplify by comparing with a more well-understood approach
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. I have a web and mobile app, and a data source Data API Gateway Lambda Using API Gateway and Lambda is one approach for performing DB operations
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is GraphQL? Open, declarative data-fetching specification != Graph database Use NoSQL, Relational, HTTP, etc. Traditional data-fetching GraphQL /posts /postInfo /postJustTitle /postsByAuthor /postNameStartsWithX /commentsOnPost /graphql
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does GraphQL work? { "id": "1", "name": "Get Milk", “priority": "1" }, { "id": “2", "name": “Go to gym", “priority": “5" },… type Query { getTodos: [Todo] } type Todo { id: ID! name: String description: String priority: Int duedate: String } query { getTodos { id name priority } } Model data with application schema Client requests what it needs Only that data is returned
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Subscriptions Near Realtime updates of data Event based mode, triggered by Mutations - Scalable model, designed as a platform for common use-cases Can be used with ANY data source in AppSync - Lambda, DynamoDB, Elasticsearch mutation addPost( id:123 title:”New post!” author:”Nadia”){ id title author } data: [{ id:123, title:”New Post!” author:”Nadia” }]
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. type Subscription { addedPost: Post @aws_subscribe(mutations: ["addPost"]) deletedPost: Post @aws_subscribe(mutations: ["deletePost"]) } type Mutation { addPost(id: ID! author: String! title: String content: String): Post! deletePost(id: ID!): Post! } subscription NewPostSub { addedPost { __typename version title content author url } } Schema
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Subscription Handshake Subscription NewPostSub { addedPost{…} } WebSocket URL and Connection Payload Secure Websocket Connection (wss://)
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Real time UI updates const AllPostsWithData = compose( graphql(AllPostsQuery, { options: { fetchPolicy: 'cache-and-network‘ }, props: (props) => ({ posts: props.data.posts, subscribeToNewPosts: params => { props.data.subscribeToMore({ document: NewPostsSubscription, updateQuery: (prev, { subscriptionData: { newPost } }) => ({ ...prev, posts: [newPost, ...prev.posts.filter(post => post.id !== newPost.id)] }) }); }); …//more code
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Offline mutations Jane Version : 2 Updated Document Jane Version : 2 Updated Document Version : 3 Updated Document Version : 1 New Document Time John John Jane goes offline Jane comes back online Version : 4 Updated Document John Jane
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Conflict Resolution and Synchronization Conflict resolution in the cloud 1. Server wins 2. Silent reject 3. Custom logic (AWS Lambda) - Optimistic version check - Extend with your own checks Optional • Client callback for Conflict Resolution is still available as a fallback { "version" : "2017-02-28", "operation" : "PutItem", "key" : { "id" : { "S" : "1" } }, "condition" : { "expression" : "attribute_not_exists(id)" } } Example: Check that an ID doesn’t already exist: "condition" : { "expression" : "someExpression" "conditionalCheckFailedHandler" : { "strategy" : "Custom", "lambdaArn" : "arn:..." } } Run Lambda if version wrong:
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Images and rich content type S3Object { bucket: String! key: String! region: String! } input S3ObjectInput { bucket: String! key: String! region: String! localUri: String! } type Profile { name: String! profilePic: S3Object! } type Mutation { updatePhoto(name: String!, profilePicInput: S3ObjectInput!): Profile }
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Client experience and configuration Offline is a write-through “Store” - Persistent storage mediums back the client “normalized cache” - Local Storage for web - SQLite on hybrid/native platforms SQLite database can be preloaded - Hydrate after installing from AppStore Offline client can be configured - Wifi only vs. wifi & carrier Queries automatically persist offline Mutations are an “optimistic write” - Control offline UI updates with “optimistic response” - Update views/lists when editing/adding data offline
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Service Cost per month • Free Tier lasts for first 12 months • Don’t forget to add Data Transfer + Database • Always review the AWS Pricing Page for latest pricing Free Tier Standard Cost Queries 250,000 $4 / million Real-time Updates 250,000 $2 / million Real-time Connection-minutes 600,000 $0.08 / million * US Pricing, as of December 1, 2017
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pricing Example (all numbers per month) • Chat application with 2,500 users • Average user connects for 1,500 minutes • Sends 1,000 and Receives 1,000 messages • 2.5M queries and 2.5M real-time updates AppSync Query 2.5M x $4/million = $10.00 AppSync Real-time 2.5M x $2/million = $5.00 AppSync Minutes 2,500 x 1,500 x $0.08/million = $0.30 Data Transfer 1KB x 2.5M = 2.4GB x $0.09 = $0.21 DynamoDB Database Free Tier (as long as store < 25Gb) Total $15.51
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Happy coding with AppSync! AWS AppSync Amazon DynamoDB AWS Lambda ElasticSearch subscriptions /graphql Resolvers DataSources
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. We need your feedback https://bit.ly/2HlWoST
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You! Kwun-Hok Chan (khchan@amazon.com)