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
Introduction to Graph API
Search
Yosuke Kurami
May 27, 2016
Programming
380
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Graph API
Yosuke Kurami
May 27, 2016
More Decks by Yosuke Kurami
See All by Yosuke Kurami
TypeScript LSP の今までとこれから
quramy
1
2.1k
フロントエンドテストの育て方
quramy
12
3.9k
App Router 悲喜交々
quramy
8
750
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
800
GraphQL あるいは React における自律的なデータ取得について
quramy
18
5.9k
Next.js App Router
quramy
15
3.9k
Fragment Composition of GraphQL
quramy
17
4.9k
reg-viz VRT tools
quramy
4
1.7k
Other Decks in Programming
See All in Programming
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
130
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
110
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
310
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
120
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.9k
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
460
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
150
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
410
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
700
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
200
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
180
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
210
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
240
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
530
Building Flexible Design Systems
yeseniaperezcruz
330
40k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
440
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
940
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
270
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
410
Code Review Best Practice
trishagee
74
20k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
The Cult of Friendly URLs
andyhume
79
7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Transcript
Introduction to graph API ~ GraphQL and Falcor ~ @Quramy
2016.05.27
About me Yosuke Kurami ǛQuarry TypeScript༻ͷVimϓϥΪϯ։ൃ͕झຯɻ http://vimawesome.com/plugin/tsuquyomi ຊۀWeb front-end Developer.
Angular (1 and 2)ͰSPAΛ։ൃ͍ͯ͠·͢
SPA
Single Page Application
Single Page Application Ƀ Ȑ {JSON} ɂ Ʌ HTTP
Today’s theme: Ƀ Ȑ {JSON} ɂ Ʌ HTTP
How to design API? endpointͷཻɺͲΕ͘Β͍͕దͰ͔͢? 1. ResourceʹશͯURLΛৼͬͯlinkͰଓʁ 2. Request͠қ͍Α͏ؔ࿈Resourcepopulateʁ
1. Thin endpoint Ƀ Ȑ { “id”: “123”, “title”: “graph
API”, “author”: “/api/v1/users/u0001” } ɂ Ʌ Get /api/v1/articles/123 Get /api/v1/users/u0001 { “id”: “u0001”, “name”: “quramy” }
1. Thin endpoint ֤ResourceURL LinkͰ݁߹͞Ε͍ͯΔɿ RESTful APIͷݪଇ௨Γ Endpointࣗମͷ࠶ར༻ੑߴ͍ RenderingʹෳRequest͕ඞཁ
2. Fat endpoint Ƀ Ȑ { “id”: “123”, “title”: “graph
API”, “author”: { “id”: “u0001”, “name”: “quramy” } } ɂ Ʌ Get /api/v1/articles/123
2. Fat endpoint Responseʹଟ͘ͷใΛωετͤ͞Δ: ը໘ͷ3FOEFSJOHָ ͦͯ͠ߴ . Endpointͷ࠶ར༻ੑ͍ ը໘ཁ݅ʹҾͬுΒΕͯɺ&OEQPJOUվम͕ඞཁͱͳΔ
View only knows what values to render Client͕Response༰ͷܾఆݖΛ࣋ͯΑ͍: • ϨεϙϯεʹͲͷؚ͕·Ε͍ͯΔ͖͔
• ඥ͍ͮͨؔ࿈Ϧιʔε͕ඞཁ͔Ͳ͏͔
Ideal endpoint Ƀ Ȑ { “id”: “123”, “title”: “graph api”,
“author”: { “id”: “u0001”, “name”: “quramy” } } ɂ Ʌ { “where”: “/article?id=123”, “properties”: [ “id”, “title”, “author”: { “properties”: [“id”, “name”] }] }
So, graph API
There are 2 major libraries GraphQL powered by Facebook http://graphql.org/
Falcor powered by Netflix http://netflix.github.io/falcor/
GraphQL
GraphQL: GraphQL is a query language import assert from "assert";
import { parse } from "graphql/language"; import { execute } from "graphql/execution"; import { schema } from "./schema"; execute(schema, parse(` { article(id :"123") { id, title, author { id, name } } } `)).then(response => { assert.deepEqual(response.data, { article: { id: "123", title: "graph api", author: { id: "u0001", name: "quramy" } } }); });
GrahpQLΛར༻͢ΔʹSchemaͷఆ͕ٛඞਢ ʮarticle(id: “123”)͕औಘՄೳʯͷใશͯSchemaʹఆ͓ٛͯ͠ ͘ඞཁ͕͋Δ GraphQL: GraphQL has solid Schema Ȑ
schema Inquire Implement
GraphQL: pros/cons • Pros: • JavaScriptҎ֎Ͱ৭ʑͳݴޠ(Java, golang, Ruby, etc…)Ͱར༻Մೳͳlibrary ͕͋Δɻ
• GraphiQlChrome Extensionɺ։ൃิॿπʔϧ๛ɻ • Cons: • शಘίετ͕ߴ͍. SchemaΛखΈͰΉͱࢮͶͦ͏. • Relay(React.js + GraphQLͷϑϨʔϜϫʔΫ)ߴػೳͰ͋ΔҰํɺGraphQL ࣗମͷRIͰ͋ΔGraphQL.jsը໘͔Β͏͜ͱΛߟ͑Δͱ૬γϣϘ͍ɻ ڧ੍తʹReact.jsʹϩοΫΠϯ͞Εͦ͏ɻ
GraphQL: Tools example e.g. Execution query with GraphiQL:
Falcor
Falcor: Access as the JSON way import { Model }
from "falcor"; import { dataSource } from "./dataSource"; import assert from "assert"; new Model({ source: dataSource, }).get( "article['123']['id', 'title']", "article['123'].author['id', 'name']" ).subscribe(response => { assert.deepEqual(response.json, { article: { "123": { id: "123", title: "graph api", author: { id: "u0001", name: "quramy" } } } }); });
Falcor “Virtual JSON Graph” ΛClient, ServerํͰڞ༗͢Δ ClientVirtual JSON Graphͷ෦ू߹ΛऔΓग़͢. Falcor:
Model as one JSON Object Ȑ JSON Graph
Falcor: pros/cons • Pros: • Έ͕୯७Ͱ͋Γɺशಘ͕༰қɻ • ७ਮͳData Fetching Library
Ͱ͋ΔͨΊɺClient-Side MVC͕ϩοΫΠϯ͞Ε ͳ͍ɻAngularͩΖ͏ͱVue.jsͩΖ͏ͱԿͰΈ߹ΘͤΒΕΔɻ • falcor.jsʹCaching, Batching, onChange, ͋Δͱخ͍͠ػೳҰ௨Γἧͬͯ ͍Δ • Cons: • Server-Side࣮جຊతʹNode.jsҰ(ҰԠC#࣮͋ΔΒ͍͚͠Ͳ…) • ࣮ߦ͠ͳ͍ͱJSON GraphͷܕใΛऔಘग़དྷͳ͍
Summary
GraphQL v.s. Falcor • GraphQLʹݫີͳSchemaఆ͕ٛଘࡏ͢ΔҰํ, Falcorʹ͓͚ ΔJSON Graphߏ҉(ͦͷ, ֶश࣮ίετΊ) •
Server-SideͱClient-Sideͷ࣮νʔϜ͕͞Ε͍ͯΔ߹ GraphQLબΜͩํ͕ྑ͍ͣɻ • ٯʹ, Front-End νʔϜ͕Endpointͷ࣮·Ͱग़དྷΔͷͰ͋Ε , FalcorͰඞཁॆͳέʔε͕ଟͦ͏ɻ
Graph API • طଘͷREST endpointΛϥοϓ͢Δ༻్ͷ߹ɺͦΕ΄ͲϝϦοτແ ͍ɻ ಛʹViewʹಛԽͨ͠EndpointઃܭΛ͍ͯ͠ΔέʔεͰҰGraphͷܗࣜ ʹਖ਼نԽ͢Δख͕͔͔ؒΔ͚͔ͩɻ • MicroServicesͷจ຺ʹ͓͍ͯ,
ෳͷDown Stream ServiceΛଋͶΔత ʹڧ͍(API Gateway, Backend-For-Fronend ) • ʮMonolithic ͳServiceΛෳׂ͢Δ࣌ʹFront͕ઌߦͯ͠ಋೖ͢Δʯͷ Α͏ͳಋೖݱ࣮త͔
Thank you!