Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GraphQL & beyond
Search
Felipe Luiz Soares
November 17, 2018
Technology
63
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL & beyond
Felipe Luiz Soares
November 17, 2018
More Decks by Felipe Luiz Soares
See All by Felipe Luiz Soares
Writing unit tests with Jest using test best practices
felipesoares6
0
200
Comecei uma tarefa e olha no que deu!
felipesoares6
0
66
HTML + CSS
felipesoares6
1
160
THE MEANING OF LIFE FRONT-END USER EXPERIENCE AND EVERYTHING
felipesoares6
0
70
BEM
felipesoares6
0
86
Read-Search-Ask
felipesoares6
1
100
Other Decks in Technology
See All in Technology
Classmethod Company Deck
satoshi7
1
680
「事実」を「計測」して、「解釈」する 〜AWS Lambdaのメモリ最適解の見つけ方〜
maimyyym
0
170
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
230
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
130
Optunaの最新リリースv5.0について
pfn
PRO
0
120
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
210
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
450
夫婦で子育てするための育児標準化
codmoninc
PRO
0
340
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
570
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
6
4.6k
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
390
パッチ更新でterraform initが落ちた日
grimoh
1
140
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
360
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
WENDY [Excerpt]
tessaabrams
14
40k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Site-Speed That Sticks
csswizardry
13
1.6k
Building Adaptive Systems
keathley
44
3.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Amusing Abliteration
ianozsvald
1
350
Transcript
GRAPHQL & beyond @felipesoares_
why how when
@felipesoares6_ felipesoares6
None
None
None
None
GraphQL is a query language
& alternative to REST
None
+
graphs -> nodes -> edges
query language SELECT * FROM
type House { edge: Person } type Person { ...
}
why?
None
3 reasons
get just what you want
enables declarative data fetching
overfetching
underfetching
nice and smooth contracts
+ typed schemas + docs
playground
clients everywhere
only exposes a single endpoint
consume the same endpoint in != ways
how?
-> schema -> queries -> mutations -> resolvers -> responses
schema
type Query { users: [User!]!, user: User! }
type User { id: ID!, name: String, email: String }
schema -> queries -> mutations resolvers responses
queries
GET /users query { users { id, name, email }
}
mutations
POST /users mutation { createUser( name: “Felipeson”, email: “
[email protected]
” )
{ id } }
schema queries mutations -> resolvers responses
resolvers
resolvers = { Query: { users: () => getUsers(), user:
(_, { id }) => getUser(id), ???: () => fetch(‘api.com/top’) } }
schema queries mutations resolvers -> responses
responses
loading
“data”: { users: [ { id: “1”, name: “Felipe Soares”,
email: “
[email protected]
” } ] } query { users { id, name, email } }
“errors”: [ { “message”: “error”, “location”: … , “fields”: ...
} ] query { users { id, name, gender } }
how how
server-side bit.ly/2OYP9IS
prisma
data-base layer
None
application layer
None
client-side bit.ly/2zRBNUq
apollo
query
import gql from ‘graphql-tag’ import { Query } from ‘react-apollo’
const GET_USERS = gql` query { users { id, name,
email } }`
<Query query={GET_USERS}> {({ load, error, data }) => { ...
} </Query>
if (load) { return <Load load={load} /> }
if (data.users) { return <List items={data} /> }
if (error) { return <Error error={error} /> }
mutation
import gql from ‘graphql-tag’ import { Mutation } from ‘react-apollo’
const CREATE_USER = gql` mutation { createUser( name: “Felipeson”, email:
“
[email protected]
” ) { id, name, email } }`
<Mutation mutation={CREATE_USER}> {( createUser , { load, error, data })
=> { ... } </Mutation>
<div> ... <UserForm submit={createUser} /> </div>
when?
is difficult to close the API contracts
overfetching underfetching
consume the same endpoint in != ways
consuming != APIs
learn something new!
thanks! @felipesoares6_ felipesoares6 bit.ly/2OYP9IS bit.ly/2zRBNUq client-side server-side