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
relay
Search
Kazuhito Hokamura
April 19, 2016
Technology
720
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
relay
Kazuhito Hokamura
April 19, 2016
More Decks by Kazuhito Hokamura
See All by Kazuhito Hokamura
TypeScriptとGraphQLで実現する 型安全なAPI実装 / TSKaigi 2024
hokaccha
5
5.1k
Kotlin製のGraphQLサーバーをNode.jsでモジュラモノリス化している話
hokaccha
0
3.8k
GraphQLの負債と向き合うためにやっていること
hokaccha
2
1.6k
ユビーのアーキテクチャに対する取り組み
hokaccha
1
490
RailsエンジニアのためのNext.js入門
hokaccha
7
22k
Cookpad Summer Internship 2021 Web Frontend
hokaccha
0
7.4k
巨大なモノリシック Rails アプリケーションの マイクロサービス化戦略 / 2019 microservices in cookpad
hokaccha
3
4.1k
巨大なRailsアプリケーションを「普通」にするための取り組み
hokaccha
1
1.1k
Web Frontend Improvement in Cookpad
hokaccha
1
1.2k
Other Decks in Technology
See All in Technology
Compose 新機能総まとめ / What's New in Jetpack Compose
yanzm
0
150
小さいから、全部わかる。— 常駐AI "xangi" のすすめ
sugupoko
0
270
Claude Code 珍プレー好プレー
shinyasaita
0
280
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
3.9k
NDIAS CTF 2026 問題解説会資料
bata_24
0
180
AI時代のエンジニアキャリアについて今一度考える
sakamoto_582
2
1.3k
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
テスト設計の本質を改めて考えてみる~生成AIを活用する時代だからこそ、作ったテストの説明性を高めよう~
yamasaki696
1
390
AWS Blocks を触ってみた/first-tach-aws-blocks
fossamagna
2
150
しぶいSRE: サーバから見えない障害にどう向き合うか。ラストワンマイルのデバッグ実践 / Shibui SRE
kanny
11
4.7k
AIに障害切り分けを全部やってもらった。 。 。 。
estie
0
380
どうして今サーバーサイドKotlinを選択したのか
nealle
0
210
Featured
See All Featured
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
890
Visualization
eitanlees
152
17k
The Curious Case for Waylosing
cassininazir
1
430
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
410
How to Talk to Developers About Accessibility
jct
2
280
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Statistics for Hackers
jakevdp
799
230k
Transcript
Relay Meguro.es #3
@hokaccha
Relay
React
GraphQL
None
GraphQL
GraphQLͱ • Facebook͕։ൃͨ͠ΫΤϦݴޠ • ΫϥΠΞϯτ/αʔόʔؒͷΓऔΓʹΘΕΔ • RESTRPCͱൺֱ͞ΕΔ
http://example.com/products/1 { "id": 1, "name": "foo", "description": "..." "image": {
"uri": "http://...", "width": 120, "height": 120 } }
http://example.com/graphql { "product" : { "id": 1, "name": "foo", "description":
"..." "image": { "uri": "http://...", "width": 120, "height": 120 } } } { product(id: 1) { id, name, description, image(size: 120) { uri, width, height } } } 3FRVFTU 3FTQPOTF
ଓ͖WebͰ http://graphql.org/
Relay
A JavaScript framework for building data-driven React Applications
ैདྷͷख๏ 1. Πϕϯτ͕τϦΨʔ͞ΕΔ 2. αʔόʔʹϦΫΤετ͢Δ 3. ϨεϙϯεΛݩʹViewΛ࠶ߏங͢Δ
$el.find('.select').on('selectProduct', id => { fetch(`/products/${id}`).then(product => { $('.name').text(product.name); $('.description').text(product.description); });
});
ReactΛͬͨ߹ 1. Πϕϯτ͕τϦΨʔ͞ΕΔ 2. αʔόʔʹϦΫΤετ͢Δ 3. ϨεϙϯεͷσʔλΛݩʹstateΛߋ৽͢Δ • ࣗಈͰView͕ߋ৽͞ΕΔ
class AppComponent extends React.Component { handleSelect(id) { fetch(`/products/{id}`).then(product => {
// update state }); } render() { return ( let { name, description } = this.props.app.product; <div> <ProductSelect onSelect={id => this.handleSelect(id)} /> <h1>{name}</h1> <div>{description}</div> </div> ); } } ໋ྩత એݴత
RelayΛͬͨ߹ 1. Πϕϯτ͕τϦΨʔ͞ΕΔ 2. ϦΫΤετΛͭ͘ΔͨΊͷΛߋ৽͢Δ • ࣗಈͰϦΫΤετΛૹΔ • ϨεϙϯεͷσʔλΛݩʹstateΛࣗಈͰߋ৽ •
View͕ࣗಈతʹߋ৽͞ΕΔ
class AppComponent extends React.Component { handleSelect(id) { this.props.relay.setVariables({ id });
} render() { let { name, description } = this.props.app.product; return ( // Reactͷྫͱಉ༷ ); } } const AppContainer = Relay.createContainer(AppComponent, { initialVariables: { id: 1 }, fragments: { app: () => Relay.QL` fragment on App { product(id: $id) { name, description } } `, }, }); એݴత
ଞʹɾɾɾ • ΫΤϦͷߏԽ • ΫΤϦͷ੩తܕνΣοΫ • σʔλͷߋ৽ • ϩʔσΟϯάͷ੍ޚ •
Ωϟογϡ • ϖʔδωʔγϣϯ • ͳͲͳͲΓͩ͘͞Μ
RelayͷͭΒ͍ͱ͜Ζ
• GraphQL/Reactͷ͕ࣝલఏ • babelΛͬͨϏϧυڥඞਢ • React΄ͲγϯϓϧͰͳ͍ • ͪΐͬͱࢼ͚ͩ͢Ͱෑډߴ͍ • ݱ࣌ͰࢿྉࢀߟΞϓϦ͕ઈతʹগͳ͍
fin.