SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Ed Lima – Solutions Architect
May 2018
Supercharging Applications with
GraphQL and AWS AppSync
@ednergizer
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A New Philosophy for Backend APIs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
App Data Challenges
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
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Traditional Data Fetching
Data
ü Trivial to set up
ü Standard HTTP Calls
Relationships
Lists with reduced information
Query support
Ordering and pagination
Notifications
/posts
/postInfo
/postJustTitle
/postsByAuthor
/postNameStartsX
/postByTag
/commentsOnPost
REST Endpoints
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Is There A Better Way
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Is GraphQL?
Describe what’s possible
with a type system
Uniform API across data stores
and APIs
Network optimized
requests and responses
Powerful developer tools Integrated
documentation and
introspection
Query language for your API
and a runtime for fulfilling
queries with existing data
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Is GraphQL?
/posts /comments /authors
REST API
posts comments authors
GraphQL API
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
subscription {
onCreateComment{
id
}
}
mutation {
createEvent(name:”Dinner”){
id
}
}
query {
getEvent(id: 1){
id
name
}
}
Queries
Read Data
Mutations
Write Data
Subscriptions
Receive Data in Real-Time
GraphQL Operations
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
type Query {
listEvents: [Event]
}
type Event {
id: ID!
name: String!
when: String!
where: String!
}
query {
listEvents {
id
name
}
}
{
"id": "1",
"name": "React Meet Up"
},
{
"id": "2",
"name": "GraphQL Party"
},
{
“id”: “3”,
“name”: “Angular Sesh”
}
...
Define your data
(Schema)
Invoke Operation Get EXACTLY what
you asked for
How To Use GraphQL
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
type Query {
listEvents: [Event]
}
type Event {
id: ID!
name: String!
when: String!
where: String!
}
query {
listEvents {
id
name
when
}
}
{
"id": "1”,
"name": "React Meet Up”,
“when”: “Tomorrow”
},
{
"id": "2",
"name": "GraphQL Party",
“when”: “Saturday”
},
{
“id”: “3”,
“name”: “Angular Sesh”,
“when”: “Next Friday”
}
...
Define your data
(Schema)
Invoke Operation Get EXACTLY what
you asked for
How To Use GraphQL
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL sounds legit!
I want to run my own GraphQL server!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Focus on Apps
Not Infrastructure
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync
© 2018, 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 façade for any
AWS service
Conflict detection and
resolution in the cloud
Enterprise security features:
IAM, Cognito, OIDC,
API keys
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How Does AppSync Work?
Create, Import or Upload
GraphQL Schema
Amazon
Elasticsearch
Amazon
DynamoDB
AWS Lambda
Connect Data
Sources
AppSync Updates Data
in Real Time and Manages
Data when Offline
__________
______________
___________
_________
___________
____________
__________
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building Data-Driven Apps With AWS Appsync
Robust, scalable storage
capable of handling
millions of events a day
Geospatial
search
Real-time
Updates
Mobile and Web
clients
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Clients receive the data
they ask for. Nothing
more, nothing less
Get many resources from
many data sources with a
single request
Self-documenting APIs with
Introspection
AWS AppSync Benefits
React Native, Android,
iOS, and Web (JS) using
the Apollo GraphQL client
Data persistence across
application restarts
Write-through mutations with
Optimistic UI
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Mix/Match Data Sources on GraphQL Types
Amazon DynamoDB
type Query {
listPosts: [Post]
searchPosts: [Post]
}
type Mutation {
addPost: Post
}
type Post {
id: ID!
content: String
description: String
ups: Int
downs: Int
}
Amazon Elasticsearch
listPosts
searchPosts
addPost
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch
Amazon DynamoDB
Browser
Mobile
device WebSocket
servers
Web servers
PubSub
servers
Subscription
/search
/taps
/taps/:id
/m_search
AWS Lambda
Third-party service
…
Real-Time App Before AppSync
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
/graphql
AWS AppSync
Subscription Amazon Elasticsearch
Amazon DynamoDB
AWS Lambda
Third-party service
Real-Time App After AppSync
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Real-Time Updates
o GraphQL subscriptions
o Event stream of mutation results
o Data synchronisation with MQTT + WebSockets
o Client managed WebSocket connection
o Automatic catch-up snapshots
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Handshake Process
subscription NewPostSub {
addedPost {…}
}
Websocket URL and Connection Payload
Secure Websocket Connection (wss://)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Data Flow in AWS AppSync
Request Template Response Template
Data Sources
1 2 3 4 5
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fine Grained Access Controls
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Access Control Checks
Simple
Only users in certain groups can perform actions
#if($hasPermission || $ctx.result.public == 'yes')
$utils.toJson($ctx.result)
#else
$utils.unauthorized()
#end
Only users in certain groups can perform actions
#if($ctx.result["Owner"] == $ctx.identity.username)
$utils.toJson($context.result);
#else
$utils.unauthorized()
#end
Advanced
Only users in certain groups can perform actions
#foreach($group in $ctx.identity.claims.get("cognito:groups"))
#if($group == "Admin")
#set($inCognitoGroup = true)
#end
#end
#if($inCognitoGroup)
{
…write/read from datasource
}
#else
$utils.unauthorized()
#end
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Data Conflicts
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
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Handle Data Conflicts In The Cloud
o Conflict detection with optimistic version check
o Conflict resolution strategies:
A. Client wins
B. Server wins
C. Silent reject
D. Custom logic in AWS Lambda
o Client callback for conflict resolution is available
"condition" : {
"expression" : "someExpression"
"conditionalCheckFailedHandler" : {
"strategy" : "Custom",
"lambdaArn" : "arn:..."
}
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
type Mutation {
updatePhoto(profilePicInput: S3ObjectInput!): Profile
}
input S3ObjectInput {
bucket: String!
key: String!
region: String!
localUri: String!
}
type Profile {
name: String!
profilePic: S3Object!
}
type S3Object {
bucket: String!
key: String!
region: String!
}
Amazon
S3
Amazon
DynamoDB
Images and Rich Content
https://github.com/aws-samples/aws-amplify-graphql
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Offline Capabilities - AppSync Client Storage
o Offline is a write-through "Store"
o Persistent storage mediums back the Apollo
normalised cache
o Local Storage for web
o AsyncStorage for React Native
o SQLite on native platforms
o Database can be preloaded
o Offline client can be configured
o WiFi only
o WiFi and cellular
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync – From November to April
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
General Availability – New Features
o Test/Debug Resolver Flows
o CloudWatch (Logs and Metrics)
o CloudFormation Support
o Subscription Resolvers
o Batch Delete/Read/Put
o AWS Amplify Support
o AWS Mobile CLI Support
o HIPPA Compliance
GA
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Test/Debug/Log
o GraphQL request logs, metrics,
and auditing
o Verbose or Errors
o Type & Field
o Overall Execution Summary
o “Stream” logs to query editor
o “Unit test” with mock context
o Arguments, Identity, Parent
o Single or List results
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Batch Operations
o Single or Multiple Tables
o Custom error handling
o Writes, Reads, and Deletes
o Order is preserved
o Web + Mobile + IoT use cases
query {
getMultipleTablesResults {
id
name
}
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Mobile CLI and AWS Amplify Support
o Quickly use GraphQL + Auth, Storage, Analytics
o Queries, Mutations, and Subscriptions
o Extension of API category, includes Sigv4 signing
o React/Angular components
o Quickly deploy with the
AWS Mobile CLI
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway AWS AppSync
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway AWS AppSync
vs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway AWS AppSync
vs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway AWS AppSync
&
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway AWS AppSync
&
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Enough Talking…
https://aws.amazon.com/appsync/resources/#Starter_applications (Angular Chat App)
https://github.com/aws-samples/aws-mobile-appsync-chat-starter-angular
https://aws.amazon.com/blogs/mobile/building-a-serverless-real-time-chat-application-with-aws-appsync/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon
Cognito
User Pools
JWT Token
GraphQL
Schema
ChatQL
Conversations
Table
Messages
Table
User Conversations
Table
Users Table
Amazon
DynamoDB
Queries and Mutations
Subscriptions
AppSync
Resolvers
User
AWS AppSync
AppSync Data Sources
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
User
1..1
1..n
1..1
1..n
1..n
User
Conversation
Conversation Messages
GraphQL Relations between NoSQL DynamoDB Tables!!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo Time
https://aws.amazon.com/appsync/resources/#Starter_applications (Angular Chat App)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Takeaways
Don’t boil the Ocean. Start small
and iterate on Offline (cache-and-
network), Real-time and Conflict
Resolution
Use UI cues with
Optimistic UI when
Offline
Take advantage of built-in
GraphQL powerful features
such as Connections
(Pagination) and Relations
(NoSQL)
It’s all about the
User Experience:
AWS AppSync = J
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Go Build with AWS AppSync and GraphQL!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Applying the Twelve-Factor Application Manifesto to
Developing Serverless Applications
The popular series will return in June & July visiting 6 cities in AU/NZ.
Be sure to register your spot as seats fill up quickly!
https://aws.amazon.com/events/lunch-and-learn/dev-lounge/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You!

Weitere ähnliche Inhalte

Was ist angesagt?

AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
Amazon Web Services Korea
 

Was ist angesagt? (20)

Visualizing Big Data Insights with Amazon QuickSight
Visualizing Big Data Insights with Amazon QuickSightVisualizing Big Data Insights with Amazon QuickSight
Visualizing Big Data Insights with Amazon QuickSight
 
AWS 101
AWS 101AWS 101
AWS 101
 
Building Event-driven Architectures with Amazon EventBridge
Building Event-driven Architectures with Amazon EventBridge Building Event-driven Architectures with Amazon EventBridge
Building Event-driven Architectures with Amazon EventBridge
 
AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
AWS 빅데이터 아키텍처 패턴 및 모범 사례- AWS Summit Seoul 2017
 
Partnership Model
Partnership ModelPartnership Model
Partnership Model
 
AWS 101: Introduction to AWS
AWS 101: Introduction to AWSAWS 101: Introduction to AWS
AWS 101: Introduction to AWS
 
Getting Started with Amazon QuickSight
Getting Started with Amazon QuickSightGetting Started with Amazon QuickSight
Getting Started with Amazon QuickSight
 
Amazon QuickSight
Amazon QuickSightAmazon QuickSight
Amazon QuickSight
 
Architecting-for-the-cloud-Best-Practices
Architecting-for-the-cloud-Best-PracticesArchitecting-for-the-cloud-Best-Practices
Architecting-for-the-cloud-Best-Practices
 
Amazon S3 Masterclass
Amazon S3 MasterclassAmazon S3 Masterclass
Amazon S3 Masterclass
 
Fundamentals of AWS Security
Fundamentals of AWS SecurityFundamentals of AWS Security
Fundamentals of AWS Security
 
AWS Control Tower
AWS Control TowerAWS Control Tower
AWS Control Tower
 
BDA311 Introduction to AWS Glue
BDA311 Introduction to AWS GlueBDA311 Introduction to AWS Glue
BDA311 Introduction to AWS Glue
 
Visualization with Amazon QuickSight
Visualization with Amazon QuickSightVisualization with Amazon QuickSight
Visualization with Amazon QuickSight
 
민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS
민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS
민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS
 
Getting Started with AWS Database Migration Service
Getting Started with AWS Database Migration ServiceGetting Started with AWS Database Migration Service
Getting Started with AWS Database Migration Service
 
Introduction to Amazon Athena
Introduction to Amazon AthenaIntroduction to Amazon Athena
Introduction to Amazon Athena
 
Deep dive into AWS IAM
Deep dive into AWS IAMDeep dive into AWS IAM
Deep dive into AWS IAM
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 

Ähnlich wie Supercharging Applications with GraphQL and AWS AppSync

Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
Amazon Web Services
 

Ähnlich wie Supercharging Applications with GraphQL and AWS AppSync (20)

Taking your Progressive Web App to the Next Level with GraphQL and AWS AppSync
Taking your Progressive Web App to the Next Level with GraphQL and AWS AppSyncTaking your Progressive Web App to the Next Level with GraphQL and AWS AppSync
Taking your Progressive Web App to the Next Level with GraphQL and AWS AppSync
 
Build a Serverless Application using GraphQL & AWS AppSync
Build a Serverless Application using GraphQL & AWS AppSyncBuild a Serverless Application using GraphQL & AWS AppSync
Build a Serverless Application using GraphQL & AWS AppSync
 
善用 GraphQL 與 AWS AppSync 讓您的 Progressive Web App (PWA) 加速進化 (Level 200)
善用  GraphQL 與 AWS AppSync 讓您的  Progressive Web App (PWA) 加速進化 (Level 200)善用  GraphQL 與 AWS AppSync 讓您的  Progressive Web App (PWA) 加速進化 (Level 200)
善用 GraphQL 與 AWS AppSync 讓您的 Progressive Web App (PWA) 加速進化 (Level 200)
 
Building Real-time Serverless Backends
Building Real-time Serverless BackendsBuilding Real-time Serverless Backends
Building Real-time Serverless Backends
 
Building Real-time Serverless Backends with GraphQL
Building Real-time Serverless Backends with GraphQLBuilding Real-time Serverless Backends with GraphQL
Building Real-time Serverless Backends with GraphQL
 
AppSync and GraphQL on iOS
AppSync and GraphQL on iOSAppSync and GraphQL on iOS
AppSync and GraphQL on iOS
 
Build your APPs in Lean and Agile Way using AWS Amplify
Build your APPs in Lean and Agile Way using AWS AmplifyBuild your APPs in Lean and Agile Way using AWS Amplify
Build your APPs in Lean and Agile Way using AWS Amplify
 
Taking your Progressive Web App to the Next Level - AWS Summit Sydney 2018
Taking your Progressive Web App to the Next Level - AWS Summit Sydney 2018Taking your Progressive Web App to the Next Level - AWS Summit Sydney 2018
Taking your Progressive Web App to the Next Level - AWS Summit Sydney 2018
 
Take Mobile and Web Apps to the Next Level with AWS AppSync and AWS Amplify
Take Mobile and Web Apps to the Next Level with AWS AppSync and AWS Amplify Take Mobile and Web Apps to the Next Level with AWS AppSync and AWS Amplify
Take Mobile and Web Apps to the Next Level with AWS AppSync and AWS Amplify
 
Introduction to GraphQL and AWS Appsync on AWS - iOS
Introduction to GraphQL and AWS Appsync on AWS - iOSIntroduction to GraphQL and AWS Appsync on AWS - iOS
Introduction to GraphQL and AWS Appsync on AWS - iOS
 
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
 
Building Real-Time Serverless Backends with GraphQL
Building Real-Time Serverless Backends with GraphQLBuilding Real-Time Serverless Backends with GraphQL
Building Real-Time Serverless Backends with GraphQL
 
Monetize Your Mobile App with Amazon Mobile Ads (MOB311) - AWS reInvent 2018.pdf
Monetize Your Mobile App with Amazon Mobile Ads (MOB311) - AWS reInvent 2018.pdfMonetize Your Mobile App with Amazon Mobile Ads (MOB311) - AWS reInvent 2018.pdf
Monetize Your Mobile App with Amazon Mobile Ads (MOB311) - AWS reInvent 2018.pdf
 
Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
Migrate an existing application RESTful API’s to GraphQL using AWS Amplify an...
 
Building Real-Time Serverless Backends with GraphQL
Building Real-Time Serverless Backends with GraphQLBuilding Real-Time Serverless Backends with GraphQL
Building Real-Time Serverless Backends with GraphQL
 
Developing Well-Architected Android Apps with AWS (MOB302) - AWS re:Invent 2018
Developing Well-Architected Android Apps with AWS (MOB302) - AWS re:Invent 2018Developing Well-Architected Android Apps with AWS (MOB302) - AWS re:Invent 2018
Developing Well-Architected Android Apps with AWS (MOB302) - AWS re:Invent 2018
 
Develop Cross-Platform Mobile Apps with React Native, GraphQL, & AWS (MOB324)...
Develop Cross-Platform Mobile Apps with React Native, GraphQL, & AWS (MOB324)...Develop Cross-Platform Mobile Apps with React Native, GraphQL, & AWS (MOB324)...
Develop Cross-Platform Mobile Apps with React Native, GraphQL, & AWS (MOB324)...
 
Bridging the Gap Between Real Time/Offline and AI/ML Capabilities in Modern S...
Bridging the Gap Between Real Time/Offline and AI/ML Capabilities in Modern S...Bridging the Gap Between Real Time/Offline and AI/ML Capabilities in Modern S...
Bridging the Gap Between Real Time/Offline and AI/ML Capabilities in Modern S...
 
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
 
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
 

Mehr von Amazon 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 AWS
Amazon 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 Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon 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
 

Mehr von 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
 

Supercharging Applications with GraphQL and AWS AppSync

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ed Lima – Solutions Architect May 2018 Supercharging Applications with GraphQL and AWS AppSync @ednergizer
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A New Philosophy for Backend APIs
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. App Data Challenges 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
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Traditional Data Fetching Data ü Trivial to set up ü Standard HTTP Calls Relationships Lists with reduced information Query support Ordering and pagination Notifications /posts /postInfo /postJustTitle /postsByAuthor /postNameStartsX /postByTag /commentsOnPost REST Endpoints
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Is There A Better Way
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What Is GraphQL? Describe what’s possible with a type system Uniform API across data stores and APIs Network optimized requests and responses Powerful developer tools Integrated documentation and introspection Query language for your API and a runtime for fulfilling queries with existing data
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What Is GraphQL? /posts /comments /authors REST API posts comments authors GraphQL API
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. subscription { onCreateComment{ id } } mutation { createEvent(name:”Dinner”){ id } } query { getEvent(id: 1){ id name } } Queries Read Data Mutations Write Data Subscriptions Receive Data in Real-Time GraphQL Operations
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. type Query { listEvents: [Event] } type Event { id: ID! name: String! when: String! where: String! } query { listEvents { id name } } { "id": "1", "name": "React Meet Up" }, { "id": "2", "name": "GraphQL Party" }, { “id”: “3”, “name”: “Angular Sesh” } ... Define your data (Schema) Invoke Operation Get EXACTLY what you asked for How To Use GraphQL
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. type Query { listEvents: [Event] } type Event { id: ID! name: String! when: String! where: String! } query { listEvents { id name when } } { "id": "1”, "name": "React Meet Up”, “when”: “Tomorrow” }, { "id": "2", "name": "GraphQL Party", “when”: “Saturday” }, { “id”: “3”, “name”: “Angular Sesh”, “when”: “Next Friday” } ... Define your data (Schema) Invoke Operation Get EXACTLY what you asked for How To Use GraphQL
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL sounds legit! I want to run my own GraphQL server!!
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Focus on Apps Not Infrastructure
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync
  • 15. © 2018, 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 façade for any AWS service Conflict detection and resolution in the cloud Enterprise security features: IAM, Cognito, OIDC, API keys
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How Does AppSync Work? Create, Import or Upload GraphQL Schema Amazon Elasticsearch Amazon DynamoDB AWS Lambda Connect Data Sources AppSync Updates Data in Real Time and Manages Data when Offline __________ ______________ ___________ _________ ___________ ____________ __________
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building Data-Driven Apps With AWS Appsync Robust, scalable storage capable of handling millions of events a day Geospatial search Real-time Updates Mobile and Web clients
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Clients receive the data they ask for. Nothing more, nothing less Get many resources from many data sources with a single request Self-documenting APIs with Introspection AWS AppSync Benefits React Native, Android, iOS, and Web (JS) using the Apollo GraphQL client Data persistence across application restarts Write-through mutations with Optimistic UI
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Mix/Match Data Sources on GraphQL Types Amazon DynamoDB type Query { listPosts: [Post] searchPosts: [Post] } type Mutation { addPost: Post } type Post { id: ID! content: String description: String ups: Int downs: Int } Amazon Elasticsearch listPosts searchPosts addPost
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Elasticsearch Amazon DynamoDB Browser Mobile device WebSocket servers Web servers PubSub servers Subscription /search /taps /taps/:id /m_search AWS Lambda Third-party service … Real-Time App Before AppSync
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. /graphql AWS AppSync Subscription Amazon Elasticsearch Amazon DynamoDB AWS Lambda Third-party service Real-Time App After AppSync
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Real-Time Updates o GraphQL subscriptions o Event stream of mutation results o Data synchronisation with MQTT + WebSockets o Client managed WebSocket connection o Automatic catch-up snapshots
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Handshake Process subscription NewPostSub { addedPost {…} } Websocket URL and Connection Payload Secure Websocket Connection (wss://)
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Data Flow in AWS AppSync Request Template Response Template Data Sources 1 2 3 4 5
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Fine Grained Access Controls
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Access Control Checks Simple Only users in certain groups can perform actions #if($hasPermission || $ctx.result.public == 'yes') $utils.toJson($ctx.result) #else $utils.unauthorized() #end Only users in certain groups can perform actions #if($ctx.result["Owner"] == $ctx.identity.username) $utils.toJson($context.result); #else $utils.unauthorized() #end Advanced Only users in certain groups can perform actions #foreach($group in $ctx.identity.claims.get("cognito:groups")) #if($group == "Admin") #set($inCognitoGroup = true) #end #end #if($inCognitoGroup) { …write/read from datasource } #else $utils.unauthorized() #end
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Data Conflicts 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
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Handle Data Conflicts In The Cloud o Conflict detection with optimistic version check o Conflict resolution strategies: A. Client wins B. Server wins C. Silent reject D. Custom logic in AWS Lambda o Client callback for conflict resolution is available "condition" : { "expression" : "someExpression" "conditionalCheckFailedHandler" : { "strategy" : "Custom", "lambdaArn" : "arn:..." } }
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. type Mutation { updatePhoto(profilePicInput: S3ObjectInput!): Profile } input S3ObjectInput { bucket: String! key: String! region: String! localUri: String! } type Profile { name: String! profilePic: S3Object! } type S3Object { bucket: String! key: String! region: String! } Amazon S3 Amazon DynamoDB Images and Rich Content https://github.com/aws-samples/aws-amplify-graphql
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Offline Capabilities - AppSync Client Storage o Offline is a write-through "Store" o Persistent storage mediums back the Apollo normalised cache o Local Storage for web o AsyncStorage for React Native o SQLite on native platforms o Database can be preloaded o Offline client can be configured o WiFi only o WiFi and cellular
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync – From November to April
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. General Availability – New Features o Test/Debug Resolver Flows o CloudWatch (Logs and Metrics) o CloudFormation Support o Subscription Resolvers o Batch Delete/Read/Put o AWS Amplify Support o AWS Mobile CLI Support o HIPPA Compliance GA
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Test/Debug/Log o GraphQL request logs, metrics, and auditing o Verbose or Errors o Type & Field o Overall Execution Summary o “Stream” logs to query editor o “Unit test” with mock context o Arguments, Identity, Parent o Single or List results
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Batch Operations o Single or Multiple Tables o Custom error handling o Writes, Reads, and Deletes o Order is preserved o Web + Mobile + IoT use cases query { getMultipleTablesResults { id name } }
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Mobile CLI and AWS Amplify Support o Quickly use GraphQL + Auth, Storage, Analytics o Queries, Mutations, and Subscriptions o Extension of API category, includes Sigv4 signing o React/Angular components o Quickly deploy with the AWS Mobile CLI
  • 36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS AppSync
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS AppSync vs
  • 39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS AppSync vs
  • 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS AppSync &
  • 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS AppSync &
  • 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Enough Talking… https://aws.amazon.com/appsync/resources/#Starter_applications (Angular Chat App) https://github.com/aws-samples/aws-mobile-appsync-chat-starter-angular https://aws.amazon.com/blogs/mobile/building-a-serverless-real-time-chat-application-with-aws-appsync/
  • 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Cognito User Pools JWT Token GraphQL Schema ChatQL Conversations Table Messages Table User Conversations Table Users Table Amazon DynamoDB Queries and Mutations Subscriptions AppSync Resolvers User AWS AppSync AppSync Data Sources
  • 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. User 1..1 1..n 1..1 1..n 1..n User Conversation Conversation Messages GraphQL Relations between NoSQL DynamoDB Tables!!!
  • 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo Time https://aws.amazon.com/appsync/resources/#Starter_applications (Angular Chat App)
  • 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Takeaways Don’t boil the Ocean. Start small and iterate on Offline (cache-and- network), Real-time and Conflict Resolution Use UI cues with Optimistic UI when Offline Take advantage of built-in GraphQL powerful features such as Connections (Pagination) and Relations (NoSQL) It’s all about the User Experience: AWS AppSync = J
  • 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Go Build with AWS AppSync and GraphQL!
  • 49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Applying the Twelve-Factor Application Manifesto to Developing Serverless Applications The popular series will return in June & July visiting 6 cities in AU/NZ. Be sure to register your spot as seats fill up quickly! https://aws.amazon.com/events/lunch-and-learn/dev-lounge/
  • 50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You!