Real-Time GraphQL - Tech9
Real-Time GraphQL - Tech9
GRAPHQL
Building real-time apps using React and
GraphQL
2
CONTENTS
04 Conclusions
05 Short Recap
Q&A Session
3
01
REAL-TIME WEB
APPS OVERVIEW
What are them ? Why do we need them ? What
are the benefits from the UX point of view ?
4
WHAT ARE REAL-TIME APPS ?
- Web/Native/Desktop Applications which enable the user to
receive information as soon as it is published by the server
5 Real-time GraphQL
WHAT ABOUT UX ?
- Instant interaction
- More engagement
- User feels the moment, the event, the people, the world
6 Real-time GraphQL
LET’S SEE SOME EXAMPLES
7 Real-time GraphQL
8 Real-time GraphQL
9 Real-time GraphQL
10 Real-time GraphQL
11 Real-time GraphQL
12 Real-time GraphQL
13 Real-time GraphQL
02
AVAILABLE
STATE-OF-THE-ART
TECHNIQUES
Which technologies ease the implementation ?
What are the available techniques and APIs ?
14 Where does GraphQL fit in ?
RELATED TECHNOLOGIES
15 Real-time GraphQL
IMPLEMENTATION TECHNIQUES
PULL PUSH
• POLLING • LIVEQUERIES
• LONG-POLLING • SUBSCRIPTIONS
16 Real-time GraphQL
POLLING
SERVER
1 2 3 4 5 6 7
CLIENT
1 3 5 6 6
POLLING
SERVER
1 2 3
CLIENT
1 2 3
19 Real-time GraphQL
LONG-POLLING
SERVER
1 2
CLIENT
1 2
LIVE QUERIES
SERVER
1 2 3 4 5 6 7 8 9
CLIENT
1 2 3 4 5 6 7 8 9
SUBSCRIPTIONS
SERVER
1 2 3 4 5 6 7 8 9
CLIENT
1 2 4 8 9
WHAT DO WE ACTUALLY SEND TO THE CLIENT ?
{ {
resourceUrl: https://my-api.beer/9 vs id: “9”,
} title: “Brewmeister Snake Venom”,
“description”: “Brain damage”,
grades: “67.5”,
palletId: “123-24-505”,
...
}
- An additional request is required in order - Most probably, additional data that the
to retrieve the necessary data about the client doesn’t need will be sent
resource
WHAT DO WE ACTUALLY SEND TO THE CLIENT ?
{
newNotifications: 18
}
27 Real-time GraphQL
1. DISMISSAL
“ One more JavaScript library ? I’m already using jQuery ! “
2. INTEREST
“ Hmm.... Maybe I should check this new library I keep hearing about !? “
3. PANIC
“ Omg! I need to learn this library right now or I’ll be completely obsolete ! ”
WHAT IS GRAPHQL ?
- Declarative data query language for APIs
- Client-specified queries
- The exact form of data that the client has asked for: NO MORE, NO LESS
GRAPHQL MUTATION
mutation {
createPerson(name: “Levi”, age: 9) {
id
}
}
GRAPHQL MAIN CONCEPTS
- Schema, Type, Field, Directives + Enum, Interfaces,
Fragments, etc...
- Query, Mutation, Subscription
GRAPHQL SUBSCRIPTION
subscription {
importantEmail: {
from
subject
isRead
}
}
39 Real-time GraphQL
SIMPLE APPLICATION EXAMPLE
- A collection of links of interest added by users related to
tech articles
- Users can vote on links
- Number of votes are updated in real-time
41 Real-time GraphQL
QUERYING THE SERVER FOR THE LINK LIST
QUERYING THE SERVER FOR THE LINK LIST
QUERYING THE SERVER FOR THE LINK LIST
ADDING A NEW LINK
VOTING ON LINK
SUBSCRIBING FOR VOTES
04
CONCLUSIONS
What’s the status at this point ?
48
WHAT’S THE STATUS AT THIS POINT ?
- GraphQL is 5 years old
- Conclusions
06
DISCLAIMER &
REFFERENCES
53
DISCLAIMER & REFERENCES
- Realtime React Apps with GraphQL by Robert Zhu
https://www.youtube.com/watch?v=AYbVMNtO-ro
56
THANK YOU