SlideShare a Scribd company logo
1 of 43
S U M M I T
LONDON
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Building Modern APIs with
GraphQL
Robert Zhu
Principal Technical Evangelist
Amazon Web Services
@rbzhu
S e s s i o n I D
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Robert Zhu
Principal Technical Evangelist
Amazon Web Services
@rbzhu
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
What is GraphQL?
• Request (GraphQL doc) -> Response (JSON)
• Language Specification
• Schema (domain-specific)
• Server Implementation
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
GraphQL is not
• A Graph database query language (*)
• A client-side state management solution
• A solution for binary streams
• Facebook Graph API
• Limited to specific database(s)
• Limited to JavaScript/NodeJS on the backend
• Limited to use with React/Relay/Web
• Limited to HTTP
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
GraphQL operations
Query  Read
Mutation  Write
Subscription  Observe Event
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Query Structure
query GetBooksForAuthor($id: ID!) {
author(id: $id) {
givenName,
nationality,
books {
title
isbn
}
}
}
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
History of GraphQL
• 2012- Built to support Facebook mobile apps
• 2015- GraphQL open sourced
• 2018- GraphQL Foundation
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
API Technologies
• REST
• SOAP
• gRPC
• Apache Thrift
• OpenAPI/Swagger
• JSON-LD
• HAL
• OData
• … and more
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
Organization Federated Centralized
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
Organization Federated Centralized
Related Ops Yes No
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
Organization Federated Centralized
Related Ops Yes No
Introspection No Yes
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
Organization Federated Centralized
Related Ops Yes No
Introspection No Yes
Data Typing Weak Strong
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
REST GraphQL
Shared Definition No Yes
Conceptual Model Resources Graphs
Organization Federated Centralized
Related Ops Yes No
Introspection No Yes
Data Typing Weak Strong
Real-time No Yes
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Challenges for Modern APIs
• Efficiency
• Predictability
• Versioning
• Security
• Documentation
• Tooling
• Caching
• Database Integration
• Real-time
• … and many more
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Efficiency
• Overfetching: response contained too much data.
• Underfetching: response did not contain enough data. Make another
network request.
• Networks suck
• Read 1 MB from SSD: 400 μs
• Packet US <-> EU: 150 ms
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Efficiency
• Avoid Overfetching and Underfetching.
• Clients to declare all the data they need in a single network request.
• Reduces the need for client-side joins, error handling, and retry logic.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Type Safety
• Predictability
• Native clients
• Code gen
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Domain Modeling
• Domain Driven Design
• Eric Evans, 2004
• Shared Language
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Versioning
• Don’t
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Tooling & Documentation
• GraphiQL provides documentation via introspection query
• Docs are never out-of-date
• IDE integrations via graphql-language-service
• GraphQL for VSCode
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Authentication and Authorization
• Authentication
• Who are you?
• Authorization
• Do you have permission?
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
HTTP Custom Protocol over TCP
Authentication
REST GraphQL RPC
Business Logic
Authentication
Persistence
Authorization
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
HTTP Custom Protocol over TCP
Authentication
REST GraphQL RPC
Business Logic
Authentication
Persistence
Authorization
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
When to use GraphQL
Cumulative
functionality
time
no design
good design
Design payoff line
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Getting GraphQL into Production
DO NOT
• Build a complete schema upfront
• Try to replace your REST API in one push
• Place business logic in the GraphQL layer
DO
• Educate your team
• Choose a solution that fits with your stack
• Build a simple query first (read-only)
• Gradually layer in features like auth/mutations
• Gradually expand schema
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Advanced use cases
• API Gateway
• 1st party vs 3rd party
• Service-to-service
• Domain Modeling: schema-first
• Persisted Queries
• Subscriptions
• Live Queries
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Ecosystem
• AWS AppSync
• https://aws.amazon.com/appsync
• Apollo
• https://www.apollographql.com/
• Prisma
• https://www.prisma.io/
• Hasura
• https://hasura.io/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Resources
• Start here: http://graphql.org
• Community: http://graphql.org/community/
• Demo: https://github.com/robzhu/tsgraphql-starwars
• AppSync: https://aws.amazon.com/appsync/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Thank you!
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Robert Zhu
Principal Technical Evangelist
Amazon Web Services
@rbzhu
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I TS U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

What's hot

GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
Introduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFIntroduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFAmazon Web Services
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Rafael Wilber Kerr
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Hafiz Ismail
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQLTomasz Bak
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLAppier
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQLMuhilvarnan V
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQLVMware Tanzu
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 

What's hot (20)

GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
Introduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFIntroduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SF
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Graphql
GraphqlGraphql
Graphql
 
GraphQL Fundamentals
GraphQL FundamentalsGraphQL Fundamentals
GraphQL Fundamentals
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
GraphQL
GraphQLGraphQL
GraphQL
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQL
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
 
Intro GraphQL
Intro GraphQLIntro GraphQL
Intro GraphQL
 
React & GraphQL
React & GraphQLReact & GraphQL
React & GraphQL
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 

Similar to Building Modern APIs with GraphQL

Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...
Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...
Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...Amazon Web Services
 
AWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLAWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLMarcia Villalba
 
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...Amazon Web Services
 
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...Amazon Web Services
 
Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Fwdays
 
GraphQL backend with AWS AppSync & AWS Lambda
GraphQL backend with AWS AppSync & AWS LambdaGraphQL backend with AWS AppSync & AWS Lambda
GraphQL backend with AWS AppSync & AWS LambdaAleksandr Maklakov
 
Serverless <3 GraphQL - AWS UG Tampere 2020
Serverless <3 GraphQL - AWS UG Tampere 2020Serverless <3 GraphQL - AWS UG Tampere 2020
Serverless <3 GraphQL - AWS UG Tampere 2020Marcia Villalba
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesAmazon Web Services
 
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...
AWS DevDay Berlin 2019 - Simplify your Web & Mobile appswith cloud-based ser...AWS DevDay Berlin 2019 - Simplify your Web & Mobile appswith cloud-based ser...
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...Darko Mesaroš
 
"Integrate your front end apps with serverless backend in the cloud", Sebasti...
"Integrate your front end apps with serverless backend in the cloud", Sebasti..."Integrate your front end apps with serverless backend in the cloud", Sebasti...
"Integrate your front end apps with serverless backend in the cloud", Sebasti...Provectus
 
Simplify your Web & Mobile applications with cloud-based serverless backends
Simplify your Web & Mobile applicationswith cloud-based serverless backendsSimplify your Web & Mobile applicationswith cloud-based serverless backends
Simplify your Web & Mobile applications with cloud-based serverless backendsSébastien ☁ Stormacq
 
善用 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)Amazon Web Services
 
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019Provectus
 
Serverless data prep with AWS Glue - ADB306 - New York AWS Summit
Serverless data prep with AWS Glue - ADB306 - New York AWS SummitServerless data prep with AWS Glue - ADB306 - New York AWS Summit
Serverless data prep with AWS Glue - ADB306 - New York AWS SummitAmazon Web Services
 
AWS App Sync (DC Startup Week 2019)
AWS App Sync (DC Startup Week 2019)AWS App Sync (DC Startup Week 2019)
AWS App Sync (DC Startup Week 2019)Rich Alberth
 
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 AppSyncAmazon Web Services
 
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 2018Amazon Web Services
 
Serverless APIs and you
Serverless APIs and youServerless APIs and you
Serverless APIs and youJames Beswick
 

Similar to Building Modern APIs with GraphQL (20)

Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...
Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...
Amplifying fullstack serverless apps with AppSync & the Amplify Framework - M...
 
AWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLAWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQL
 
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...
Next generation intelligent data lakes, powered by GraphQL & AWS AppSync - MA...
 
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...
Build secure, offline, real-time-enabled mobile apps - MAD304 - Atlanta AWS S...
 
Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"
 
GraphQL backend with AWS AppSync & AWS Lambda
GraphQL backend with AWS AppSync & AWS LambdaGraphQL backend with AWS AppSync & AWS Lambda
GraphQL backend with AWS AppSync & AWS Lambda
 
Serverless <3 GraphQL - AWS UG Tampere 2020
Serverless <3 GraphQL - AWS UG Tampere 2020Serverless <3 GraphQL - AWS UG Tampere 2020
Serverless <3 GraphQL - AWS UG Tampere 2020
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...
AWS DevDay Berlin 2019 - Simplify your Web & Mobile appswith cloud-based ser...AWS DevDay Berlin 2019 - Simplify your Web & Mobile appswith cloud-based ser...
AWS DevDay Berlin 2019 - Simplify your Web & Mobile apps with cloud-based ser...
 
"Integrate your front end apps with serverless backend in the cloud", Sebasti...
"Integrate your front end apps with serverless backend in the cloud", Sebasti..."Integrate your front end apps with serverless backend in the cloud", Sebasti...
"Integrate your front end apps with serverless backend in the cloud", Sebasti...
 
Simplify your Web & Mobile applications with cloud-based serverless backends
Simplify your Web & Mobile applicationswith cloud-based serverless backendsSimplify your Web & Mobile applicationswith cloud-based serverless backends
Simplify your Web & Mobile applications with cloud-based serverless backends
 
Simplify front end apps.pdf
Simplify front end apps.pdfSimplify front end apps.pdf
Simplify front end apps.pdf
 
Simplify front end apps.pdf
Simplify front end apps.pdfSimplify front end apps.pdf
Simplify front end apps.pdf
 
善用 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)
 
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019
"How to build real-time backends", Martin Beeby, AWS Dev Day Kyiv 2019
 
Serverless data prep with AWS Glue - ADB306 - New York AWS Summit
Serverless data prep with AWS Glue - ADB306 - New York AWS SummitServerless data prep with AWS Glue - ADB306 - New York AWS Summit
Serverless data prep with AWS Glue - ADB306 - New York AWS Summit
 
AWS App Sync (DC Startup Week 2019)
AWS App Sync (DC Startup Week 2019)AWS App Sync (DC Startup Week 2019)
AWS App Sync (DC Startup Week 2019)
 
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
 
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
 
Serverless APIs and you
Serverless APIs and youServerless APIs and you
Serverless APIs and you
 

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
 

Building Modern APIs with GraphQL

  • 1. S U M M I T LONDON
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Building Modern APIs with GraphQL Robert Zhu Principal Technical Evangelist Amazon Web Services @rbzhu S e s s i o n I D
  • 3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Robert Zhu Principal Technical Evangelist Amazon Web Services @rbzhu
  • 4. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T What is GraphQL? • Request (GraphQL doc) -> Response (JSON) • Language Specification • Schema (domain-specific) • Server Implementation
  • 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T GraphQL is not • A Graph database query language (*) • A client-side state management solution • A solution for binary streams • Facebook Graph API • Limited to specific database(s) • Limited to JavaScript/NodeJS on the backend • Limited to use with React/Relay/Web • Limited to HTTP
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T GraphQL operations Query  Read Mutation  Write Subscription  Observe Event
  • 8. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 9. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 10. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 11. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 12. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 13. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 14. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Query Structure query GetBooksForAuthor($id: ID!) { author(id: $id) { givenName, nationality, books { title isbn } } }
  • 15. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T History of GraphQL • 2012- Built to support Facebook mobile apps • 2015- GraphQL open sourced • 2018- GraphQL Foundation
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T API Technologies • REST • SOAP • gRPC • Apache Thrift • OpenAPI/Swagger • JSON-LD • HAL • OData • … and more
  • 18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL
  • 19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes
  • 20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized Related Ops Yes No
  • 23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized Related Ops Yes No Introspection No Yes
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized Related Ops Yes No Introspection No Yes Data Typing Weak Strong
  • 25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized Related Ops Yes No Introspection No Yes Data Typing Weak Strong Real-time No Yes
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Challenges for Modern APIs • Efficiency • Predictability • Versioning • Security • Documentation • Tooling • Caching • Database Integration • Real-time • … and many more
  • 27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Efficiency • Overfetching: response contained too much data. • Underfetching: response did not contain enough data. Make another network request. • Networks suck • Read 1 MB from SSD: 400 μs • Packet US <-> EU: 150 ms
  • 28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Efficiency • Avoid Overfetching and Underfetching. • Clients to declare all the data they need in a single network request. • Reduces the need for client-side joins, error handling, and retry logic.
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Type Safety • Predictability • Native clients • Code gen
  • 30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Domain Modeling • Domain Driven Design • Eric Evans, 2004 • Shared Language
  • 31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Versioning • Don’t
  • 32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Tooling & Documentation • GraphiQL provides documentation via introspection query • Docs are never out-of-date • IDE integrations via graphql-language-service • GraphQL for VSCode
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
  • 34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Authentication and Authorization • Authentication • Who are you? • Authorization • Do you have permission?
  • 35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T HTTP Custom Protocol over TCP Authentication REST GraphQL RPC Business Logic Authentication Persistence Authorization
  • 36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T HTTP Custom Protocol over TCP Authentication REST GraphQL RPC Business Logic Authentication Persistence Authorization
  • 37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T When to use GraphQL Cumulative functionality time no design good design Design payoff line
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Getting GraphQL into Production DO NOT • Build a complete schema upfront • Try to replace your REST API in one push • Place business logic in the GraphQL layer DO • Educate your team • Choose a solution that fits with your stack • Build a simple query first (read-only) • Gradually layer in features like auth/mutations • Gradually expand schema
  • 39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Advanced use cases • API Gateway • 1st party vs 3rd party • Service-to-service • Domain Modeling: schema-first • Persisted Queries • Subscriptions • Live Queries
  • 40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Ecosystem • AWS AppSync • https://aws.amazon.com/appsync • Apollo • https://www.apollographql.com/ • Prisma • https://www.prisma.io/ • Hasura • https://hasura.io/
  • 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Resources • Start here: http://graphql.org • Community: http://graphql.org/community/ • Demo: https://github.com/robzhu/tsgraphql-starwars • AppSync: https://aws.amazon.com/appsync/
  • 42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Thank you! S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Robert Zhu Principal Technical Evangelist Amazon Web Services @rbzhu
  • 43. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I TS U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.