SlideShare une entreprise Scribd logo
1  sur  33
OFFLINE-ENABLED REAL-TIME
MOBILE APPS WITH GRAPHQL
ADRIAN HALL
SR. DEVELOPER ADVOCATE
AMAZON WEB SERVICES
A TYPICAL MOBILE APP
CLOUD CONNECTIVITY: CHATTINESS
REST Calls:
/inbox/messages
/inbox/messages/1
/inbox/messages/2
/inbox/messages/3
/inbox/messages/4
/…
A typical page will make 20-30 HTTP calls to render the page
CLOUD CONNECTIVITY: TOO MUCH INFORMATION
/inbox/messages/1
{
“subject”: “Inky Verification Robot”,
“content”: ”Inky Email….”,
“from”: “verify@inky.com”,
“to”: “olivialong24@gmail.com”,
“sent”: ”20180628T113223.00Z”
“thread”: [ 14, 22 ],
“priority”: 3
…
}
Up to 80% of the data returned by the server is not needed
CLOUD CONNECTIVITY: RESPONSIVENESS
Cloud response
200-300ms
DATA DRIVEN APP REQUIREMENTS
Flexible Client
Schema
Instant Access
ScalabilityOffline Data
Minimal
Data Transfer
Security
Use a UI
driven data
protocol like
GraphQL
Use a mobile
client SDK
with an
offline cache
Use
serverless
technologies
in the cloud
GRAPHQL
GRAPHQL: A DATA API FOR YOUR UI
• Security boundary defined by service
• Client asks for the data they need
• Subscriptions keep the data fresh
• Network and battery efficient
http://graphql.org/learn
GRAPHQL IN ACTION: QUERIES
• All queries start with ”query”
• Operation defined by client:
• Operation name
• Return shape
• Use variables to pass data
• Supports compiled queries
GRAPHQL IN ACTION: SCHEMA
• Schema defines the security perimeter
• Requests and responses are strongly typed
• Self-documenting
• Easy to use code generation tools
• Advanced typing
http://graphql.org/learn
GRAPHQL IN ACTION: MASTER-DETAIL VIEW
GRAPHQL IN ACTION: POWERFUL DEVELOPER TOOLS
• Introspection
• Code Generation
• IDE Integrations
• Data Visualizations
GRAPHQL IN ACTION: API EVOLUTION
• Every request specifies all the fields required
• We know what is being used
• Deprecate fields to let introspection tools know
IS REST DEAD THEN?
Use REST:
• When you leverage HTTP
• HTTP-layer Caching
• Content Types
• Hypermedia (HATEOS)
• For Resources
Use GraphQL:
• When data drives UI
• Structured data
• Query-driven
• Client-driven UI development
Pick the appropriate protocol for your use case
OFFLINE CAPABLE CLIENT
APOLLO CLIENT
• Declarative data fetching
• Zero-config caching
• Real-time subscriptions (with provider)
• Bring your own HTTP provider
• Extensive client support
https://www.apollographql.com/client
APOLLO CLIENT: CACHING
https://www.apollographql.com/client
• Query results automatically cached
• Prepare to react to changes in the data set
• Mutations queued until server available
• Use platform-specific handlers to detect network changes
• Mutations drive internal query updates
• Optimistic responses & refetch query list
QUERY SEMANTICS (REACT SAMPLE)
import gql from "graphql-tag";
import { Query } from "react-apollo";
const GET_DOGS = gql` { dogs { id breed } } `;
const Dogs = ({ onDogSelected }) => (
<Query query={GET_DOGS}>
{({ loading, error, data }) => {
if (loading) return "Loading...";
if (error) return `Error! ${error.message}`;
return (
<select name="dog" onChange={onDogSelected}>
{data.dogs.map(dog => (
<option key={dog.id} value={dog.breed}> {dog.breed} </option>
))}
</select>
);
}}
</Query>
);
GraphQL Query
Network loading…
Data (almost) always
available
APOLLO CLIENT: SUBSCRIPTIONS
https://www.apollographql.com/client
• Proactively update the cache when changes happen
• Register a callback to receive updates
• Callback can update internal state
• Requires provider support
LONG TERM OFFLINE: USE A LOCAL COPY
sync
Sync
Service
Data
Repository
Views
Mobile
App
• Use a regular SQLite database
• Add an operations queue table for mutations
• Ensure IDs are GUIDs
• Add updated timestamp and deleted flag for incremental sync
• Optimistically update the SQLite database
SERVERLESS BACKEND
SERVERLESS IN A NUTSHELL
• No servers to manage
• Scale as the service needs
• Pay for what you use
• Focus on your application
Amazon Cognito Amazon Pinpoint
Amazon DynamoDBAWS Lambda
AWS AppSync
OPTIONS FOR DATA SERVICES
• GraphQL Service in Docker Container
• Standard container can be run anywhere
• Must manage container as well as code
• Deal with scaling and security separately – use AWS Fargate
• GraphQL as a Service
• Little to no code needed for most use cases
• Scaling and security managed for you
INTRODUCING 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
BUILD A GRAPHQL API WITH AWS APPSYNC
AWS APPSYNC: DATA SOURCES
Amazon DynamoDB
Amazon Elasticsearch Service
AWS Lambda
NoSQL Service with global table replication.
Complex search capabilities including fuzzy matching and geospatial.
Support any data source with custom resolvers.
• Combine different data sources into one API easily.
• Supports relationships between data sources.
AWS APPSYNC: AUTHN / AUTHZ
API KEY
Unauthenticated
Amazon Cognito
Group Permissions
User Directory
AWS IAM
Role Permissions
Federated Identities
OpenID Connect
Claim-based Permissions
User Directory
AWS APPSYNC: REQUEST & RESPONSE MAPPING
• Convert to/from backend requirements
• Written in Velocity Template Language (VTL)
• Standard Templates for common operations
• Get item, Paged list, Save item, Delete item, Batch add, etc.
• Implement fine-grained authorization controls
• Personal data, friends-only, etc.
AWS APPSYNC: REAL-TIME DATA FOR ANY DATA SOURCE
• Near real-time updates of data
• Event-based model, triggered by mutations in GraphQL
• Use with any data source in AWS AppSync
• Implemented as MQTT over WebSockets
mutation addPost(id:123
title:”New post!”
author:”Adrian”) {
id
title
author
}
data: [{
id:123,
title:”New Post!”
author:”Adrian”
}]
Demo: Create a GraphQL Service in 2 Minutes
BEST PRACTICES FOR DATA DRIVEN APPLICATIONS
Prepare for offline
use cases
Use the right
data protocol
Be kind to the
mobile device
Anticipate success
RESOURCES:
• https://graphql.org/learn
• https://www.apollographql.com/client
• https://aws.amazon.com/appsync
THANK YOU
Adrian Hall
Sr. Developer Advocate
AWS Mobile
adrianha@amazon.com
@FizzyInTheHall
@FizzyInTheHall

Contenu connexe

Dernier

Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 

Dernier (20)

Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 

En vedette

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

En vedette (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Offline Enabled Real-time Mobile Apps with GraphQL

  • 1. OFFLINE-ENABLED REAL-TIME MOBILE APPS WITH GRAPHQL ADRIAN HALL SR. DEVELOPER ADVOCATE AMAZON WEB SERVICES
  • 3. CLOUD CONNECTIVITY: CHATTINESS REST Calls: /inbox/messages /inbox/messages/1 /inbox/messages/2 /inbox/messages/3 /inbox/messages/4 /… A typical page will make 20-30 HTTP calls to render the page
  • 4. CLOUD CONNECTIVITY: TOO MUCH INFORMATION /inbox/messages/1 { “subject”: “Inky Verification Robot”, “content”: ”Inky Email….”, “from”: “verify@inky.com”, “to”: “olivialong24@gmail.com”, “sent”: ”20180628T113223.00Z” “thread”: [ 14, 22 ], “priority”: 3 … } Up to 80% of the data returned by the server is not needed
  • 6. DATA DRIVEN APP REQUIREMENTS Flexible Client Schema Instant Access ScalabilityOffline Data Minimal Data Transfer Security Use a UI driven data protocol like GraphQL Use a mobile client SDK with an offline cache Use serverless technologies in the cloud
  • 8. GRAPHQL: A DATA API FOR YOUR UI • Security boundary defined by service • Client asks for the data they need • Subscriptions keep the data fresh • Network and battery efficient http://graphql.org/learn
  • 9. GRAPHQL IN ACTION: QUERIES • All queries start with ”query” • Operation defined by client: • Operation name • Return shape • Use variables to pass data • Supports compiled queries
  • 10. GRAPHQL IN ACTION: SCHEMA • Schema defines the security perimeter • Requests and responses are strongly typed • Self-documenting • Easy to use code generation tools • Advanced typing http://graphql.org/learn
  • 11. GRAPHQL IN ACTION: MASTER-DETAIL VIEW
  • 12. GRAPHQL IN ACTION: POWERFUL DEVELOPER TOOLS • Introspection • Code Generation • IDE Integrations • Data Visualizations
  • 13. GRAPHQL IN ACTION: API EVOLUTION • Every request specifies all the fields required • We know what is being used • Deprecate fields to let introspection tools know
  • 14. IS REST DEAD THEN? Use REST: • When you leverage HTTP • HTTP-layer Caching • Content Types • Hypermedia (HATEOS) • For Resources Use GraphQL: • When data drives UI • Structured data • Query-driven • Client-driven UI development Pick the appropriate protocol for your use case
  • 16. APOLLO CLIENT • Declarative data fetching • Zero-config caching • Real-time subscriptions (with provider) • Bring your own HTTP provider • Extensive client support https://www.apollographql.com/client
  • 17. APOLLO CLIENT: CACHING https://www.apollographql.com/client • Query results automatically cached • Prepare to react to changes in the data set • Mutations queued until server available • Use platform-specific handlers to detect network changes • Mutations drive internal query updates • Optimistic responses & refetch query list
  • 18. QUERY SEMANTICS (REACT SAMPLE) import gql from "graphql-tag"; import { Query } from "react-apollo"; const GET_DOGS = gql` { dogs { id breed } } `; const Dogs = ({ onDogSelected }) => ( <Query query={GET_DOGS}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <select name="dog" onChange={onDogSelected}> {data.dogs.map(dog => ( <option key={dog.id} value={dog.breed}> {dog.breed} </option> ))} </select> ); }} </Query> ); GraphQL Query Network loading… Data (almost) always available
  • 19. APOLLO CLIENT: SUBSCRIPTIONS https://www.apollographql.com/client • Proactively update the cache when changes happen • Register a callback to receive updates • Callback can update internal state • Requires provider support
  • 20. LONG TERM OFFLINE: USE A LOCAL COPY sync Sync Service Data Repository Views Mobile App • Use a regular SQLite database • Add an operations queue table for mutations • Ensure IDs are GUIDs • Add updated timestamp and deleted flag for incremental sync • Optimistically update the SQLite database
  • 22. SERVERLESS IN A NUTSHELL • No servers to manage • Scale as the service needs • Pay for what you use • Focus on your application Amazon Cognito Amazon Pinpoint Amazon DynamoDBAWS Lambda AWS AppSync
  • 23. OPTIONS FOR DATA SERVICES • GraphQL Service in Docker Container • Standard container can be run anywhere • Must manage container as well as code • Deal with scaling and security separately – use AWS Fargate • GraphQL as a Service • Little to no code needed for most use cases • Scaling and security managed for you
  • 24. INTRODUCING 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
  • 25. BUILD A GRAPHQL API WITH AWS APPSYNC
  • 26. AWS APPSYNC: DATA SOURCES Amazon DynamoDB Amazon Elasticsearch Service AWS Lambda NoSQL Service with global table replication. Complex search capabilities including fuzzy matching and geospatial. Support any data source with custom resolvers. • Combine different data sources into one API easily. • Supports relationships between data sources.
  • 27. AWS APPSYNC: AUTHN / AUTHZ API KEY Unauthenticated Amazon Cognito Group Permissions User Directory AWS IAM Role Permissions Federated Identities OpenID Connect Claim-based Permissions User Directory
  • 28. AWS APPSYNC: REQUEST & RESPONSE MAPPING • Convert to/from backend requirements • Written in Velocity Template Language (VTL) • Standard Templates for common operations • Get item, Paged list, Save item, Delete item, Batch add, etc. • Implement fine-grained authorization controls • Personal data, friends-only, etc.
  • 29. AWS APPSYNC: REAL-TIME DATA FOR ANY DATA SOURCE • Near real-time updates of data • Event-based model, triggered by mutations in GraphQL • Use with any data source in AWS AppSync • Implemented as MQTT over WebSockets mutation addPost(id:123 title:”New post!” author:”Adrian”) { id title author } data: [{ id:123, title:”New Post!” author:”Adrian” }]
  • 30. Demo: Create a GraphQL Service in 2 Minutes
  • 31. BEST PRACTICES FOR DATA DRIVEN APPLICATIONS Prepare for offline use cases Use the right data protocol Be kind to the mobile device Anticipate success
  • 33. THANK YOU Adrian Hall Sr. Developer Advocate AWS Mobile adrianha@amazon.com @FizzyInTheHall @FizzyInTheHall