Real-Time API’s with GraphQL
Sandeep Singh
initialspark.co.uk @initial_spark
Slide 2
Slide 2 text
◦ What is GraphQL ?
◦ Why it exists and the problems it aims to solve ?
◦ GraphQL core concepts
◦ Real-Time API’s – the what, why and how
Agenda @initial_spark
Slide 3
Slide 3 text
GraphQL is a declarative query language for
your API
@initial_spark
Slide 4
Slide 4 text
@initial_spark
Slide 5
Slide 5 text
○Built on specification
○Hierarchical
○Client‐driven
○Strongly typed
What is GraphQL? @initial_spark
Slide 6
Slide 6 text
Q: Why GraphQL?
@initial_spark
Slide 7
Slide 7 text
○Efficiency
○Predictability
○Versioning
○Caching
○Security, tooling, documentation and more
Modern API considerations @initial_spark
Slide 8
Slide 8 text
Let’s look at an example…
@initial_spark
Slide 9
Slide 9 text
@initial_spark
Slide 10
Slide 10 text
Efficiency
@initial_spark
Slide 11
Slide 11 text
Efficiency @initial_spark
GraphQL API
Mongo DB
AWS Lamba
REST API
SOAP Service
HTTP
TCP/IP
HTTP
SOAP
Optimisted data for each channel
Slide 12
Slide 12 text
Versioning
Evolution
@initial_spark
Slide 13
Slide 13 text
Tooling & DX
@initial_spark
Slide 14
Slide 14 text
Introspection
{
__schema{
types{
name
}
}
}
• Query schema, types and fields
• Build tools
o Auto complete / Validate (graphiql)
o Code generation
o Documentation
@initial_spark
Slide 15
Slide 15 text
GraphQL Core Concepts
@initial_spark
Slide 16
Slide 16 text
Schema
Type System Query
Language
GraphQL Core Concepts @initial_spark
Slide 17
Slide 17 text
GraphQL Core Concepts - Resolvers @initial_spark
Slide 18
Slide 18 text
Schema
Type System Query
Language
o Operations
• Queries – read
• Mutations – write
• Subscriptions –
real-time
o Alias
o Fragments
GraphQL Core Concepts @initial_spark
◦ Real time events
◦ Idea: Server pushes data to client when something ‘interesting’
occurs
◦ The client defines the shape of the data pushed to it
Subscriptions – Event Based @initial_spark
Slide 26
Slide 26 text
◦ The initial state is large, but the incremental change sets are small
◦ You care about low-latency updates in the case of specific events,
e.g. chat application where users expect to receive new messages in
a matter of seconds
Subscriptions – When to use @initial_spark