Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
An Introduction to GraphQL (ReactJS SF Bay Area)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
jnwng
April 12, 2018
Technology
0
140
An Introduction to GraphQL (ReactJS SF Bay Area)
A beginner-level introduction to GraphQL
jnwng
April 12, 2018
Tweet
Share
More Decks by jnwng
See All by jnwng
Evolving the Graph
jnwng
1
290
Introduction to GraphQL (Reactathon)
jnwng
0
170
Providing Flexibility Through Constraint
jnwng
0
89
Introduction to GraphQL
jnwng
1
550
Going GraphQL First - ReactSF
jnwng
0
200
Going GraphQL First
jnwng
5
740
keeping up with javascript
jnwng
3
1k
Presentations 101
jnwng
1
250
SViOS Meetup: HTTP Live Streaming
jnwng
2
410
Other Decks in Technology
See All in Technology
AI時代のPMに求められるのは 「Ops」と「Enablement」
shimotaroo
1
480
Introduction to Bill One Development Engineer
sansan33
PRO
0
350
ファシリテーション勉強中 その場に何が求められるかを考えるようになるまで / 20260123 Naoki Takahashi
shift_evolve
PRO
3
400
Amazon ElastiCacheのコスト最適化を考える/Elasticache Cost Optimization
quiver
0
280
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
OCI技術資料 : OS管理ハブ 概要
ocise
2
4.3k
ドキュメントからはじめる未来のソフトウェア
pkshadeck
4
2k
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
360
システムのアラート調査をサポートするAI Agentの紹介/Introduction to an AI Agent for System Alert Investigation
taddy_919
0
420
Riverpod3.xで実現する実践的UI実装
fumiyasac0921
2
350
AI開発をスケールさせるデータ中心の仕組みづくり
kzykmyzw
0
180
ゼロから始めたFindy初のモバイルアプリ開発
grandbig
2
480
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
55
49k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Abbi's Birthday
coloredviolet
1
4.6k
ラッコキーワード サービス紹介資料
rakko
1
2.1M
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Designing for Timeless Needs
cassininazir
0
120
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
810
Into the Great Unknown - MozCon
thekraken
40
2.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
200
Utilizing Notion as your number one productivity tool
mfonobong
2
200
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
130
Transcript
An Introduction To GraphQL ReactJS SF Bay Area, 4/12/2018
Jon Wong Frontend Infrastructure, Coursera @jnwng 2
Who is this talk for? ▪ Folks who deal with
complex React applications ▪ Folks who use APIs (like REST) on a day-to-day basis ▪ Folks who want to know more about GraphQL! 3
Runtime ▪ Clients ▪ Servers ▪ Tools What We’re Covering
in GraphQL Language ▪ Schemas ▪ Queries ▪ Operations 4
What is GraphQL? Taken straight from GraphQL.org
Describe your Data 6 type Project { name: String tagline:
String contributors: [User] }
Ask for What You Want 7 query { project(name: "GraphQL")
{ tagline } }
Get Predictable Results 8 query { project(name: "GraphQL") { tagline
} } { "project": { "tagline": "A query language for APIs" } } GraphQL JSON
Schemas Describing possible data
Describe everything that is possible ▪ All possible data results
are described by the server. 10
Describe everything that is possible 11 type Project { name:
String tagline: String contributors: [User] }
Discoverability ▪ Exploring an API is no longer a burden
12
GraphiQL 13
Validation ▪ Every query is validated against the GraphQL schema
▪ No runtime errors for making API calls 14
The GraphQL schema gives us the basis of everything that
is possible when communicating to the server from the client. 15
Queries Reading your data
17 A simple query query { project(name: "GraphQL") { tagline
} } { "project": { "tagline": "A query language for APIs" } }
18 A simple query with a name query AQueryWithAName {
project(name: "GraphQL") { tagline } }
19 A simple query with arguments query ($projectName: String!){ project(name:
$projectName) { tagline } }
20 … which requires variables query ($projectName: String!){ project(name: $projectName)
{ tagline } } { “projectName”: “react” } query variables
query { react: project(name: “react”){ tagline } graphql: project(name: “graphql”)
{ tagline } } 21 A simple query with aliases
22 … which returns what you expect { “react”: {
“tagline”: “A JavaScript library for building user interfaces” }, “graphql”: { “tagline”: “A query language for APIs” } }
Fragments 23 fragment Contributors on Project { name contributors }
Spreading a fragment in a query 24 query { project(name:
"GraphQL") { tagline ...Contributors } } query { project(name: "GraphQL") { tagline name contributors } } These turn out the same!
GraphQL queries allow the client to declare exactly what it
needs, in the form that it needs it in. 25
React && Queries Declarative + Composable
27 A typical React application
28 … broken down into components.
29 This is how we normally get the data fetch(‘/courses/machine-learning’)
fetch(‘/partners/?course=machine-learning’) fetch(‘/instructors/?course=machine-learning’)
30 A complex GraphQL query query CoursePage { course(slug: “machine-learning”)
{ title description partner { name logo } instructor { name title photoUrl } } }
31 A complex GraphQL query query CoursePage { course(slug: “machine-learning”)
{ title description ...Partner ...Instructor } }
32 A complex GraphQL query fragment Partner on Course {
partner { name logo } } fragment Instructor on Course { instructor { name title photoUrl } }
33 ▪ Components can be more portable ▪ Components are
more self-sufficient. Every component can declare its own data requirements
Clients Managing your data
Clients make it easier to manage data Relay Apollo 35
Caching ▪ Clients provide advanced caching for GraphQL queries. 36
Caching 37 query ListView { allBooks { id name }
} query DetailView ($id: ID) { bookById(id: $id) { name } }
The GraphQL HoC 38 const ProjectTitle = ({ data: {
project: { tagline } } }) => <h1>{tagline}</h1>; export default graphql(gql` query { project(name: “graphql”) { tagline } } `)(ProjectTitle);
Clients make adopting GraphQL in your application a breeze. 39
Servers Serving your data
Mapping types to resolvers 41 const typeDefs = ` type
Query { projects: [Project] } type Project { name: String tagline: String contributors: [User] } `; const resolvers = { Query: { projects: () => fetch('https://api.com/project’) }, };
Every field can be resolved separately. 42 const resolvers =
{ Project: { name: () => return ‘graphql’, tagline: () => 'A query language for APIs’, contributors: () => fetch(‘/users/?projectName=graphql’) } };
GraphQL servers are flexible 43 ▪ They can act as
proxies to existing data ▪ They can also become the business logic layer itself
Tools Supercharging your data
GraphiQL 45
`eslint-plugin-graphql` 46 Catch invalid API calls at compile-time
`apollo-codegen` 47 Catch runtime errors at compile-time
GraphQL enables an entire ecosystem of tools to make developers
more effective. 48
▪ GraphQL makes it really simple to query lots of
data, no matter where it is. 49 In Summary
▪ Just like React, GraphQL can break down complexity into
composable, reusable pieces 50 In Summary
▪ GraphQL.org ▪ GraphQL.com ▪ https://launchpad.graphql.com/ new 51 How to
Get Started
THANKS! 52 @jnwng Presentation template by SlidesCarnival