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 を Relay と Phoenix で実装する
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Yas Okada
December 09, 2015
Programming
1.4k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL を Relay と Phoenix で実装する
Yas Okada
December 09, 2015
Other Decks in Programming
See All in Programming
Jetpack Compose Mechanisms
skydoves
3
820
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
430
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
440
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
180
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
190
Featured
See All Featured
Between Models and Reality
mayunak
4
500
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
We Have a Design System, Now What?
morganepeng
55
8.4k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
360
Six Lessons from altMBA
skipperchong
29
4.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
570
Designing for humans not robots
tammielis
254
26k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Transcript
(SBQI2-Λ3FMBZͱ 1IPFOJYͰ࣮͢Δ :BT0LBEB
ܦྺ w ࣄͱͯ͠ͷϓϩάϥϚʔྺɿ͙̍̕Β͍ w ݱࡏɺϑϦʔΤϯδχΞ w σεΫτοϓ༻ΞϓϦɿ͙̍̌Β͍ w "OESPJE༻ΞϓϦɿ͙̑Β͍ w
ͱ͖Ͳ͖J048FC4FSWFSͷ͓ख͍
ݱࡏ w ݄͔ΒΞΧπΩͷ৽نࣄۀ෦ w 8FCαʔϏεͷ։ൃ w αʔόɿ&MJYJS1IPFOJY w ϑϩϯτɿ3FBDU3FEVY w
Α͏͘ɺHVMQ &4 BOTJCMFɺɾɾɾͳͲ ͰʹೖΕΔΑ͏ʹͳ͖ͬͯͨ
(SBQI2-
8FC"1*ͷελΠϧ 3&45 w ϦιʔεΛ63*Ͱද͠ɺ w (&51045165%&-&5&Ͱૢ࡞͢Δ w (&5VTFSTϢʔβϦετऔಘ w (&5VTFSTϢʔβऔಘ
w 165VTFSTϢʔβߋ৽
8FC"1*ͷελΠϧ ΦʔέετϨʔγϣϯ w ΫϥΠΞϯτͷ͋Δը໘ʹಛԽͨ͠"1* w ྫ͑ɺ"1*ը໘ w (&5WJFXUPQ هࣄͷϦετɺϢʔβεςʔλεɺఱؾʜ
"1*ͷελΠϧ 3&45 ΦʔέετϨʔγϣϯ %#ΞΫηε "1* ˓গͳ͍ɾγϯϓϧ ☓ଟ͍ɾෳࡶ ൚༻ੑ ˓ ☓
"1* ˓গͳ͍ ☓ଟ͍ "1*ը໘ ☓ଟ͍ ˓গͳ͍ ΫϥΠΞϯτ ͝ͱͷ࠷దԽ ☓ ˓
ཧͷ"1* w αʔόͷ࡞Γ͕γϯϓϧͰ w ൚༻తͰ w "1*͕࠷খݶͰ w ΫϥΠΞϯτ͔Βͷ௨৴͕গͳ͘ w
σόΠεը໘ͳͲͷ༻్͝ͱʹ࠷దԽͰ͖Δ
(SBQI2- w 'BDFCPPL͕։ൃ w ΫΤϦʔܕͷ"1* w ̎ͭͷૢ࡞ w RVFSZͱNVUBUJPO query
Q { viewer { totalCount todos(first:3) { edges { node { id text } } } } }
(SBQI2- w αʔόͰTDIFNBΛఆٛ w TDIFNBϦιʔεͷܕͳͲ w ΫϥΠΞϯτऔಘ͢ΔϦιʔεɺϦιʔεͷɺ ϑΟʔϧυΛࣗ༝ʹΈཱͯΔ͜ͱ͕Ͱ͖Δɻ
%&.0
3FMBZ
3FMBZ w (SBQI2-ͷػೳΛ3FBDUʹՃ͢Δ+BWB4DSJQU ͷϥΠϒϥϦ
3FBDU w 8FCͷ7JFXͷͨΊͷ+BWB4DSJQUϥΠϒϥϦ w 7JSUVBM%0. w ίϯϙʔωϯτࢦ w TUBUF w
มߋ͢Δͱؔ࿈͢Δίϯϙʔωϯτ͕ߋ৽͞ΕΔ w QSPQT w JNNVUBCMF͔ΒࢠσʔλΛ͢
3FBDU class Comment extends React.Component { render() { return (
<div className="comment"> <h2 className="commentAuthor"> {this.props.comment.author} </h2> {this.props.comment.text} </div> ); } } class CommentList extends React.Component { : componentDidMount() { $.ajax({ success: function(data) { this.setState({comments: data}); }.bind(this), }); } render() { let commentNodes = this.state.comments.map(comment => { return ( <Comment comment={comment} key={comment.id} /> ); }); return ( <div className="commentList"> {commentNodes} </div> ); } }
3FMBZ w 3FBDUʹ(SBQI2-ͷػೳΛՃ͢ΔϥΠϒϥϦ w (SBQI2-ʹΑΔσʔλͷऔಘɾߋ৽ w QSPQTͷө w TUBUF3FMBZ͕ཧ
3FMBZ 5PEP-JTU export default Relay.createContainer(TodoList, { fragments: {
viewer: () => Relay.QL` fragment on User { completedCount, todos(status: $status, first: $limit) { edges { node { id, ${Todo.getFragment('todo')}, }, }, }, } `, }, }); class TodoList extends React.Component { renderTodos() { return this.props.viewer.todos.edges.map(edge => <Todo key={edge.node.id} todo={edge.node} viewer={this.props.viewer} /> ); } render() { return ( <section className="main"> <ul className="todo-list"> {this.renderTodos()} </ul> </section> ); } }
3FMBZ export default Relay.createContainer(Todo, { fragments: { todo: () =>
Relay.QL` fragment on Todo { complete, id, text, } `, }, }); 5PEP class Todo extends React.Component { render() { return ( <li> <div className=“view"> <input checked={this.props.todo.complete} className="toggle" onChange={this._handleCompleteChange} type="checkbox" /> <label> {this.props.todo.text} </label> <button className="destroy" onClick={this._handleDestroyClick} /> </div> </li> ); } }
͜͜·ͰͰɺ w 3FBDU 3FMBZ w (SBQI2-ͷΫϥΠΞϯτͷ४උ͕Ͱ͖ͨ w αʔόʁ
&MJYJS
&MJYJS w ؔܕݴޠ select( where( from(w in Weather), [w], w.population
> 0), [w], w.city)
&MJYJS w ύΠϓϥΠϯ w લͷؔͷΓΛɺ࣍ͷؔͷୈ̍Ҿʹ͢ɻ w ؔΛॎʹදݱ͢Δ͜ͱͰɺؔͷؔྲྀΕΛΘ͔Γ ͘͢දݱͰ͖Δɻ from(w in
Weather) |> where([w], w.population > 0) |> select([w], w.city)
&MJYJS w ϚΫϩ w %4-ʢಠࣗͷݴޠʣΛ࡞Δ͜ͱ͕Ͱ͖Δ from(w in Weather) |> where([w],
w.population > 0) |> select([w], w.city)
&DUP w σʔλϕʔεૢ࡞༻ͷϞδϡʔϧ w 03.ͷΑ͏ͳׂɻ w %4-Ͱσʔλϕʔεͷૢ࡞Λهड़
&DUP %4- w จͷߏ&MJYJS͕ͩɺҙຯಠࣗʹղऍ w ྫɿԼͷྫͰɺMJTUNBQͷදݱ͕ͩɺGV͕ಥવొ͠ ͍ͯͯɺ&MJYJSͱͯ͠ਖ਼͘͠ͳ͍ w TFMFDUMJNJUͷ ͷத&DUPઐ༻ͷݴޠ
%-4 feed = RssFeed |> Query.select([f], %{ id: f.id, title: f.title }) |> Query.limit([u], 1) |> Repo.all
&DUP &DUPΛͬͯ(SBQI2-ͷRVFSZͰࢦఆ͞Εͨ ϑΟʔϧυͷΈΛऔಘ͢Δɻ (SBQI2-"1*ʹσʔλΛฦ͢ʹʁ
&DUP w TFMFDUʹࢦఆ͢ΔΧϥϜΛߏங͠ͳ͚Ε ͳΒ͍ɻ w TFMFDUͷ ͷத&DUPಠࣗͷධՁ͕ͩɺ ֎ʹग़Δͱ&MJYJSͱͯ͠ධՁ͞ΕΔͷ Ͱɺ֎ͰߏஙͰ͖ͳ͍ɻ cols
= %{ title: f.title, summary: f.summary } feed = RssFeed |> Query.select([f], cols) |> Query.limit([u], 1) |> Repo.all fragment on RssFeed { title, subtitle, summary }
&DUP w ৽͍͠%4-ʢখ͞ͳϚΫϩʣΛ࡞͢Δ w 2VFSZ&YTFMFDU <lUJUMFz lTVNNBSZz> w &DUPͷTFMFDUԿΛ͍ͯ͠Δ͔ʁ
w Ecto.Query.Select.build/4ΛݺΜͰ͍Δɻ defmodule Ecto.Query do defmacro select(query, binding, expr) do Select.build(query, binding, expr, __CALLER__) end end
&DUP defmodule QueryEx do defmacro select(query, cols) do quote do
Ecto.Query.Builder.Select.build(unquote(query), [{:f, [], nil}], ɹɹɹɹɹɹQueryEx.make_select(unquote(cols)), __ENV__) |> Code.eval_quoted |> elem(0) end end def make_select(cols) do {:%{}, [], make_col([], cols)} end defp make_col(cols, [col|tl]) do cols = Keyword.put(cols, String.to_atom(col), ɹɹɹɹɹɹɹɹɹɹɹɹɹɹ{{:., [], [{:f, [], nil}, String.to_atom(col)]}, [], []}) make_col(cols, tl) end defp make_col(cols, []) do cols end end
%&.0
(SBQI2-Λ3FMBZͱ 1IPFOJYͰ࣮͢Δ
1IPFOJY w &MJYJSͷ3VCZPO3BJMTͷΑ͏ͳαʔόͷϑϨʔϜ ϫʔΫ
ࢀߟࢿྉ w IUUQUFDICMPHOFUqJYDPNFNCSBDJOHEJ⒎FSFODFT JOTJEFOFUqJYIUNM w IUUQGBDFCPPLHJUIVCJPHSBQIRM w IUUQTGBDFCPPLHJUIVCJPSFBDU w IUUQTGBDFCPPLHJUIVCJPSFMBZ
w αϯϓϧίʔυ w IUUQTHJUIVCDPNZBTVIJSPPLBEBBLUTL TBNQMF@QIPFOJY@SFBDU