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
2
56
GraphQl, Front queries made easy
How to deal with graphql on client-side
Igor Halfeld
December 01, 2018
Tweet
Share
More Decks by Igor Halfeld
See All by Igor Halfeld
Modular monoliths with fastify
igorhalfeld
0
190
How to migrate legacy frontend?
igorhalfeld
1
130
Patterns for perfect components in Vue.js
igorhalfeld
0
110
Clean Architecture no Front-end (update 2021-05-11)
igorhalfeld
0
59
Step by step I followed a career in software
igorhalfeld
0
700
Using AI to create memes
igorhalfeld
0
530
Deninho, the TS children
igorhalfeld
1
220
Micro Front-ends, what they don't tell you
igorhalfeld
0
390
CSS in JavaScripto, the anti-pattern that is good
igorhalfeld
1
98
Other Decks in Programming
See All in Programming
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
Grafana:建立系統全知視角的捷徑
blueswen
0
320
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
620
CSC307 Lecture 07
javiergs
PRO
0
550
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
190
AI巻き込み型コードレビューのススメ
nealle
0
100
Implementation Patterns
denyspoltorak
0
280
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.8k
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
400
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
220
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
76
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
A Soul's Torment
seathinner
5
2.2k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
First, design no harm
axbom
PRO
2
1.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Abbi's Birthday
coloredviolet
1
4.7k
Designing for Timeless Needs
cassininazir
0
130
Code Review Best Practice
trishagee
74
20k
Faster Mobile Websites
deanohume
310
31k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
110
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