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
GraphQl, Front queries made easy
Search
Igor Halfeld
December 01, 2018
Programming
64
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQl, Front queries made easy
How to deal with graphql on client-side
Igor Halfeld
December 01, 2018
More Decks by Igor Halfeld
See All by Igor Halfeld
Modular monoliths with fastify
igorhalfeld
0
210
How to migrate legacy frontend?
igorhalfeld
1
140
Patterns for perfect components in Vue.js
igorhalfeld
0
130
Clean Architecture no Front-end (update 2021-05-11)
igorhalfeld
0
74
Step by step I followed a career in software
igorhalfeld
0
710
Using AI to create memes
igorhalfeld
0
540
Deninho, the TS children
igorhalfeld
1
230
Micro Front-ends, what they don't tell you
igorhalfeld
0
410
CSS in JavaScripto, the anti-pattern that is good
igorhalfeld
1
110
Other Decks in Programming
See All in Programming
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
290
プロポーザルを書いてもらう
pvcresin
0
570
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
140
バグを直したら useEffect が消えた
colorful12
3
690
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
280
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
340
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
400
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
150
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
170
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
380
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
280
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Automating Front-end Workflow
addyosmani
1369
210k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
300
Site-Speed That Sticks
csswizardry
13
1.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
Transcript
GraphQl. Front-end queries made easy.
Igor Halfeld Software Engineer & Consultancy igorluiz.me - @IgorHalfeld
Conheça minha história. Onde tudo começou…
None
Objetivo. Onde eu quero chegar…
None
Vamos contextualizar. Como chegamos até aqui?
ZONA DARK SOAP REST #TRISTEZA #SEMCROSSFIT
"Analisarmos alternativas, como o REST. (…) Ficamos frustrados com as
diferenças entre os dados que queríamos e as requests que eram necessárias para obtê-los.” Lee Byron
2012. GraphQl é criado pelo Facebook apenas para uso interno.
2015. É liberado como open source!
Que rolê é esse?
Duas partes. Consumir no front-end e fazer no back-end. *dar
uma olhada nos conceitos antes.
GraphQl Server Data Sources Clients JSON bonitão lindão GraphQl Queries
Resolvers
None
REST tem vários endpoints em que cada um retorna dados
fixos. GraphQl tem um único endpoint que retorna uma estrutura flexível.
REST GET - /users/:id { “name”: “Igor Halfeld”, “email”: “
[email protected]
”,
“state”: “RJ" } GraphQl POST - /graphql { “data”: { “name”: “Igor Halfeld” } } { query { Users (id: “666") { name } } }
3 pilares. Query, Mutation, Subscription.
REST GET GraphQl POST PUT DELETE Query Mutations
{ query { users { name, email } } }
{ query { users (id: “666”) { name, email } } } GET - /users/:id GET - /users
{ mutation { createUser ( name: "Igor Luiz”, email: “
[email protected]
"
) { name, email } } } CREATE - /users { mutation { updateUser ( name: “Halfeld Igor” ) { name, email } } } PUT - /users/:id
{ mutation { deleteUser (id: “666”) { name, email }
} } DELETE - /users
None
O que muda no front é… Basicamente, saber fazer GraphQl
SDL.
type Users { name: String! email: String! skills: [String]! addresses:
[Address] } type Address { street: String, number: Number } GraphQl SDL (Schema Definition Language)
{ Query { users (id: “666”) { name, height (unit:
METERS) } } } Resolvers <3
{ Query { users { admin (role: ADMIN) { …userFields
} accountants (role: ACCOUNTANT) { …userFields } } } } fragment userFields on User { user, name } Fragments
{ Query { users ($id: ID) { name, email }
} } { id: “666" } Variables
Client de GraphQl. Se é tudo POST, eu posso usar
o axios, certo?
Sim, mas não! Você precisa! Justamente para aproveitar melhor os
benefícios do graphql.
None
Certeza que vai fazer a query de forma certa. Cache
built-it: performance. Consistência na UI: Cache reativo.
None
None
None
Como tamo agora?
None
None
None
Tooling. Ferramental daóra.
None
None
GraphQl faker.
GraphQl Voyager.
DEMO TIME!
bit.ly/demo-floripa
Obrigado! igorluiz.me/talks - @IgorHalfeld