© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Introduzione a GraphQL
AWS AppSync & Amplify
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Brief intro to Serverless
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is serverless?
No infrastructure provisioning,
no management
Automatic scaling
Pay for value Highly available and secure
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS
Lambda
AWS
Fargate
Amazon
API Gateway
Amazon
SNS
Amazon
SQS
AWS
Step Functions
COMPUTE
DATA STORES
INTEGRATION
Amazon Aurora
Serverless
Amazon
S3
Amazon
DynamoDB
AWS
AppSync
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL
© 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.
GraphQL APIs
Open, declarative data-fetching specification
!= Graph database
Use NoSQL, Relational, HTTP, etc.
Traditional data-fetching GraphQL
/posts
/postInfo
/postJustTitle
/postsByAuthor
/postNameStartsWithX
/commentsOnPost
/posts
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Schema
{
"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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL
Int: A signed 32‐bit integer.
Float: A signed double-precision floating-point value.
String: A UTF‐8 character sequence.
Boolean: true or false.
ID: The ID scalar type represents a unique identifier, often
used to refetch an object or as the key for a cache. The ID
type is serialized in the same way as a String; however,
defining it as an ID signifies that it is not intended to be
human‐readable.
Scalar types
GraphQL + AppSync
AWSDate: accepts date strings of the form YYYY-MM-DD.
AWSTime: accepts time strings of the form hh:mm:ss.sss.
AWSDateTime: accepts datetime strings of the form YYYY-MM-
DDThh:mm:ss.sssZ.
AWSTimestamp: represents the number of seconds that have
elapsed since 1970-01-01T00:00Z.
AWSEmail: represents an Email
AWSJSON: represents a JSON string that complies with RFC
8259.
AWSURL: represents a valid URL string.
AWSPhone: represents a valid Phone Number
AWSIPAddress: scalar type represents a valid IPv4 or IPv6
address string.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Types
Schema
type Event {
id: ID!
name: String
where: String
when: String
description: String
comments: [Comment]
}
type Comment {
commentId: String!
eventId: ID!
content: String!
createdAt: String!
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Mutation
Schema
Mutation
type Mutation {
createEvent(
name: String!,
when: String!,
where: String!,
description: String!
): Event
deleteEvent(id: ID!): Event
commentOnEvent(
eventId: ID!,
content: String!,
createdAt: String!
): Comment
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Query
Schema
Mutation
Query
type Query {
getEvent(id: ID!): Event
listEvents(
limit: Int,
nextToken: String
): EventConnection
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Subscription
Schema
Mutation
Query
Subscription type Subscription {
onComments(eventId: String!): Comment
@aws_subscribe(mutations: ["commentOnEvent"])
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL Spec - Subscription
Schema
Mutation
Query
Subscription type Subscription {
onComments(eventId: String!): Comment
@aws_subscribe(mutations: ["commentOnEvent"])
}
type Mutation {
…
commentOnEvent(
eventId: ID!,
content: String!,
createdAt: String!
): Comment
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GraphQL - Summary
Schema
Mutation
Query
Subscription
Realtime? YES
Batching? YES
Pagination? YES
Relations? YES
Aggregations? YES
Search? YES
Offline? YES
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What are the GraphQL benefits?
• Rapid prototyping and iteration
• Co-location of data requirements & application views
o Implementations aren’t encoded in the server
• Data behavior control
o Batching, request/response and real-time
• Bandwidth optimization (N+1 problem)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
I want to run my own GraphQL server!!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync – Intro
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is AWS AppSync?
AWS AppSync is a managed service for application data
using GraphQL with real-time capabilities and an offline
programming model.
Real-time
Collaboration
Offline Programming
Model with Sync
Flexible Database
Options
Fine-grained
Access Control
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync Benefits
Get many resources from
many data sources with a
single request
Self-documenting APIs with
Introspection
Clients receive the data
they ask for. Nothing
more, nothing less
React Native, Android,
iOS, and Web (JS) using
the Apollo GraphQL client
Data persistence across
application restarts
Write-through mutations with
optimistic UI
© 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.
AWS AppSync and GraphQL Subscription
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”
}]
Websockets over MQTT
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync – Data Sources, Auth and more
DynamoDB
Lambda
Function Elasticsearch
Service
GraphQL
Schema
Upload
Schema
GraphQL
Query
Mutation
Subscription
Real-time
Offline
AppSync
API
Cognito
User Pool
Legacy
Application
Amazon RDS
HTTPS
endpoint
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does AppSync connect to my data sources?
{
"version": "2017-02-28",
"operation": "GetItem",
"key": {
"company_id": $util.dynamodb.toDynamoDBJson($ctx.args.id),
}
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync – Debug Resolver Flow
Amazon CloudWatch logs
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What about Offline access?
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AppSync Client Storage
• Offline is a write-through "Store"
• Persistent storage mediums back the Apollo normalized
cache
• Local Storage for web
• AsyncStorage for React Native
• SQLite on native platforms
• Database can be preloaded
• Offline client can be configured
• WiFi only
• WiFi and cellular
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS AppSync – Conflict Resolution
Conflict resolution in the cloud
a. Server wins
b. Client wins
c. Silent reject
d. 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:
© 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
AI/ML
© 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.
Resources
• https://docs.aws.amazon.com/appsync/lates
t/devguide/
• https://github.com/aws-amplify/amplify-js
• https://github.com/aws/aws-appsync-
community
• https://github.com/awslabs
• https://www.amplify.com/

More Related Content

PDF
Modern Applications Web Day | Impress Your Friends with Your First Serverless...
PPTX
Serverless Developer Experience I AWS Dev Day 2018
PPTX
Containers State of the Union I AWS Dev Day 2018
PPTX
Serverless Architectural Patterns I AWS Dev Day 2018
PDF
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
PDF
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
POTX
Serverless: State of The Union I AWS Dev Day 2018
PDF
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Modern Applications Web Day | Impress Your Friends with Your First Serverless...
Serverless Developer Experience I AWS Dev Day 2018
Containers State of the Union I AWS Dev Day 2018
Serverless Architectural Patterns I AWS Dev Day 2018
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
Serverless: State of The Union I AWS Dev Day 2018
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019

Similar to Introduzione a GraphQL (20)

PDF
Marcia Villalba "Developing Serverless Applications with GraphQL"
PDF
GraphQL backend with AWS AppSync & AWS Lambda
PDF
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
PDF
Rapid mobile development using GraphQL and AWS AppSync
PDF
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
PDF
AWS Stockholm Summit 19- Building serverless applications with GraphQL
PDF
API moderne e real-time per applicazioni innovative
PDF
Serverless <3 GraphQL - AWS UG Tampere 2020
PDF
AppSync in real world - pitfalls, unexpected benefits & lessons learnt
PPTX
Serverless GraphQL. AppSync 101
PPTX
AWS App Sync (DC Startup Week 2019)
PDF
20200520 - Como empezar a desarrollar aplicaciones serverless
PDF
Simplify your Web & Mobile applications with cloud-based serverless backends
PDF
"Integrate your front end apps with serverless backend in the cloud", Sebasti...
PDF
20200513 Getting started with AWS Amplify
PDF
App Sync, 모바일 개발을 위한 GraphQL as a Service - 트랙1, Community Day 2018 re:Invent 특집
PPTX
A talk on AWS AppSync
PDF
Full Stack Serverless 1st Edition Nader Dabit
PDF
Full Stack Serverless 1st Edition Nader Dabit
PDF
REST API に疲れたあなたへ贈る GraphQL 入門
Marcia Villalba "Developing Serverless Applications with GraphQL"
GraphQL backend with AWS AppSync & AWS Lambda
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
Rapid mobile development using GraphQL and AWS AppSync
Danilo Poccia - Real-Time Serverless Backends with GraphQL - Codemotion Berli...
AWS Stockholm Summit 19- Building serverless applications with GraphQL
API moderne e real-time per applicazioni innovative
Serverless <3 GraphQL - AWS UG Tampere 2020
AppSync in real world - pitfalls, unexpected benefits & lessons learnt
Serverless GraphQL. AppSync 101
AWS App Sync (DC Startup Week 2019)
20200520 - Como empezar a desarrollar aplicaciones serverless
Simplify your Web & Mobile applications with cloud-based serverless backends
"Integrate your front end apps with serverless backend in the cloud", Sebasti...
20200513 Getting started with AWS Amplify
App Sync, 모바일 개발을 위한 GraphQL as a Service - 트랙1, Community Day 2018 re:Invent 특집
A talk on AWS AppSync
Full Stack Serverless 1st Edition Nader Dabit
Full Stack Serverless 1st Edition Nader Dabit
REST API に疲れたあなたへ贈る GraphQL 入門
Ad

More from Commit University (20)

PDF
Accessibilità ed equità digitale: un impegno, non una scelta
PDF
GitHub Copilot:vediamo chi comanda - Commit University.pdf
PDF
Contract Driven Development - Branch 2024.pdf
PPTX
Cybersecurity & AI: Illusioni e Speranze
PDF
Migliorare la Developer Experience in un mondo Cloud Native
PPTX
Scopri come sfruttare la potenza della Hybrid RAG
PDF
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
PDF
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
PPTX
Alla scoperta dei Vector Database e dei RAG
PDF
Nell’iperspazio con Rocket: il Framework Web di Rust!
PDF
Crea il tuo assistente AI con lo Stregatto (open source python framework)
PDF
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
PDF
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
PDF
Slide-10years.pdf
PDF
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
PDF
Vue.js slots.pdf
PPTX
Commit - Qwik il framework che ti stupirà.pptx
PPTX
Sviluppare da zero una Angular Web App per la PA
PDF
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
PDF
Prisma the ORM that node was waiting for
Accessibilità ed equità digitale: un impegno, non una scelta
GitHub Copilot:vediamo chi comanda - Commit University.pdf
Contract Driven Development - Branch 2024.pdf
Cybersecurity & AI: Illusioni e Speranze
Migliorare la Developer Experience in un mondo Cloud Native
Scopri come sfruttare la potenza della Hybrid RAG
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
Alla scoperta dei Vector Database e dei RAG
Nell’iperspazio con Rocket: il Framework Web di Rust!
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Slide-10years.pdf
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Vue.js slots.pdf
Commit - Qwik il framework che ti stupirà.pptx
Sviluppare da zero una Angular Web App per la PA
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Prisma the ORM that node was waiting for
Ad

Recently uploaded (20)

PPTX
communication and presentation skills 01
PDF
Design Guidelines and solutions for Plastics parts
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
ChapteR012372321DFGDSFGDFGDFSGDFGDFGDFGSDFGDFGFD
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PPT
Total quality management ppt for engineering students
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
introduction to high performance computing
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
737-MAX_SRG.pdf student reference guides
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
communication and presentation skills 01
Design Guidelines and solutions for Plastics parts
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
ChapteR012372321DFGDSFGDFGDFSGDFGDFGDFGSDFGDFGFD
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Total quality management ppt for engineering students
III.4.1.2_The_Space_Environment.p pdffdf
introduction to high performance computing
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Abrasive, erosive and cavitation wear.pdf
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Information Storage and Retrieval Techniques Unit III
737-MAX_SRG.pdf student reference guides
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Fundamentals of Mechanical Engineering.pptx
Module 8- Technological and Communication Skills.pptx
August 2025 - Top 10 Read Articles in Network Security & Its Applications

Introduzione a GraphQL

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Introduzione a GraphQL AWS AppSync & Amplify
  • 2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Brief intro to Serverless
  • 3. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure
  • 4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda AWS Fargate Amazon API Gateway Amazon SNS Amazon SQS AWS Step Functions COMPUTE DATA STORES INTEGRATION Amazon Aurora Serverless Amazon S3 Amazon DynamoDB AWS AppSync
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL
  • 6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. /posts /comments /authors REST API posts comments authors GraphQL API What is GraphQL?
  • 7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL APIs Open, declarative data-fetching specification != Graph database Use NoSQL, Relational, HTTP, etc. Traditional data-fetching GraphQL /posts /postInfo /postJustTitle /postsByAuthor /postNameStartsWithX /commentsOnPost /posts
  • 8. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Schema { "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
  • 9. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Int: A signed 32‐bit integer. Float: A signed double-precision floating-point value. String: A UTF‐8 character sequence. Boolean: true or false. ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable. Scalar types GraphQL + AppSync AWSDate: accepts date strings of the form YYYY-MM-DD. AWSTime: accepts time strings of the form hh:mm:ss.sss. AWSDateTime: accepts datetime strings of the form YYYY-MM- DDThh:mm:ss.sssZ. AWSTimestamp: represents the number of seconds that have elapsed since 1970-01-01T00:00Z. AWSEmail: represents an Email AWSJSON: represents a JSON string that complies with RFC 8259. AWSURL: represents a valid URL string. AWSPhone: represents a valid Phone Number AWSIPAddress: scalar type represents a valid IPv4 or IPv6 address string.
  • 10. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Types Schema type Event { id: ID! name: String where: String when: String description: String comments: [Comment] } type Comment { commentId: String! eventId: ID! content: String! createdAt: String! }
  • 11. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Mutation Schema Mutation type Mutation { createEvent( name: String!, when: String!, where: String!, description: String! ): Event deleteEvent(id: ID!): Event commentOnEvent( eventId: ID!, content: String!, createdAt: String! ): Comment }
  • 12. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Query Schema Mutation Query type Query { getEvent(id: ID!): Event listEvents( limit: Int, nextToken: String ): EventConnection }
  • 13. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Subscription Schema Mutation Query Subscription type Subscription { onComments(eventId: String!): Comment @aws_subscribe(mutations: ["commentOnEvent"]) }
  • 14. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL Spec - Subscription Schema Mutation Query Subscription type Subscription { onComments(eventId: String!): Comment @aws_subscribe(mutations: ["commentOnEvent"]) } type Mutation { … commentOnEvent( eventId: ID!, content: String!, createdAt: String! ): Comment }
  • 15. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GraphQL - Summary Schema Mutation Query Subscription Realtime? YES Batching? YES Pagination? YES Relations? YES Aggregations? YES Search? YES Offline? YES
  • 16. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What are the GraphQL benefits? • Rapid prototyping and iteration • Co-location of data requirements & application views o Implementations aren’t encoded in the server • Data behavior control o Batching, request/response and real-time • Bandwidth optimization (N+1 problem)
  • 17. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. I want to run my own GraphQL server!!
  • 18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync – Intro
  • 19. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is AWS AppSync? AWS AppSync is a managed service for application data using GraphQL with real-time capabilities and an offline programming model. Real-time Collaboration Offline Programming Model with Sync Flexible Database Options Fine-grained Access Control
  • 20. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync Benefits Get many resources from many data sources with a single request Self-documenting APIs with Introspection Clients receive the data they ask for. Nothing more, nothing less React Native, Android, iOS, and Web (JS) using the Apollo GraphQL client Data persistence across application restarts Write-through mutations with optimistic UI
  • 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. AWS AppSync and GraphQL Subscription 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” }] Websockets over MQTT
  • 23. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync – Data Sources, Auth and more DynamoDB Lambda Function Elasticsearch Service GraphQL Schema Upload Schema GraphQL Query Mutation Subscription Real-time Offline AppSync API Cognito User Pool Legacy Application Amazon RDS HTTPS endpoint
  • 24. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does AppSync connect to my data sources? { "version": "2017-02-28", "operation": "GetItem", "key": { "company_id": $util.dynamodb.toDynamoDBJson($ctx.args.id), } }
  • 25. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync – Debug Resolver Flow Amazon CloudWatch logs
  • 26. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What about Offline access?
  • 27. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AppSync Client Storage • Offline is a write-through "Store" • Persistent storage mediums back the Apollo normalized cache • Local Storage for web • AsyncStorage for React Native • SQLite on native platforms • Database can be preloaded • Offline client can be configured • WiFi only • WiFi and cellular
  • 28. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS AppSync – Conflict Resolution Conflict resolution in the cloud a. Server wins b. Client wins c. Silent reject d. 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:
  • 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 AI/ML
  • 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. Resources • https://docs.aws.amazon.com/appsync/lates t/devguide/ • https://github.com/aws-amplify/amplify-js • https://github.com/aws/aws-appsync- community • https://github.com/awslabs • https://www.amplify.com/