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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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.8k
App Router 悲喜交々
quramy
8
740
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
790
GraphQL あるいは React における自律的なデータ取得について
quramy
18
5.9k
Next.js App Router
quramy
15
3.9k
Fragment Composition of GraphQL
quramy
17
4.8k
reg-viz VRT tools
quramy
4
1.7k
Other Decks in Programming
See All in Programming
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.6k
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
250
初めてのKubernetes 本番運用でハマった話
oku053
0
120
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
180
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
700
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
300
Creating Composable Callables in Contemporary C++
rollbear
0
210
継続モナドとリアクティブプログラミング
yukikurage
3
590
Claude Team Plan導入・ガイド
tk3fftk
0
190
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
170
共通化で考えるべきは、実装より公開する型だった
codeegg
0
230
Featured
See All Featured
Making Projects Easy
brettharned
120
6.7k
GitHub's CSS Performance
jonrohan
1033
470k
Evolving SEO for Evolving Search Engines
ryanjones
0
240
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
420
A Tale of Four Properties
chriscoyier
163
24k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
330
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
330
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
460
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.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!