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
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
phperだってパンチカードでコーディングしたい
o0h
PRO
0
170
Are APIs Still Relevant in the AI Era?
soyuka
0
410
SREの越境 / SRE Collaboration
y0hgi
2
300
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
710
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
100
JRuby: Past, Present, and Future
headius
0
220
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.2k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
410
iOSDCのペンライトを自動制御したい!
akkeylab
0
360
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
7
1.6k
mrbgem 三角測量 開発
ogom
0
190
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
520
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Six Lessons from altMBA
skipperchong
29
4.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Git: the NoSQL Database
bkeepers
PRO
433
67k
What's in a price? How to price your products and services
michaelherold
247
13k
Docker and Python
trallard
47
4.2k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
So, you think you're a good person
axbom
PRO
2
2.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
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