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
作って学ぶ GraphQL
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kyo
October 15, 2022
Programming
1.5k
0
Share
作って学ぶ GraphQL
Go Conference mini 2022 Autumn IN Sendai の発表スライドです。
GraphQL についてまとめてみました。
kyo
October 15, 2022
More Decks by kyo
See All by kyo
GoとWasmでつくる軽量ブラウザUI
keyl0ve
0
800
Go言語で行うメール解析
keyl0ve
0
2k
Gopher Enablement Internship
keyl0ve
0
880
Other Decks in Programming
See All in Programming
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
430
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
810
Oxlintのカスタムルールの現況
syumai
5
990
New "Type" system on PicoRuby
pocke
1
440
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
2.6k
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
480
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
220
Oxcを導入して開発体験が向上した話
yug1224
4
280
関係性から理解する"同一性"の型用語たち
pvcresin
2
630
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
250
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
440
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.4k
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
160
Building an army of robots
kneath
306
46k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
580
The Spectacular Lies of Maps
axbom
PRO
1
790
Why Our Code Smells
bkeepers
PRO
340
58k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
820
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
440
Scaling GitHub
holman
464
140k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
350
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Transcript
作って学ぶ GraphQL Go Conference mini 2022 Autumn IN SENDAI Kyo
Sato
Shopify No-Code Mobile-App VIP Appify ってなに?
Contents - 自己紹介 - GraphQL について - 終わりに
Contents - 自己紹介 - GraphQL について - 終わりに
- GraphQL について理解を深めたかった - GraphQL を導入することで得られる メリットについて整理したかった - Appify で使用されている技術
理由
自己紹介
自己紹介 Name: きょー。 HN: Keyl0ve Hobby: 温泉、旅行、食べ歩 Univ. : 会津大学
B3
GraphQLについて 目標: - GraphQL という技術を広める - 実際にサーバを立てて試してもらう
GraphQL - Facebook - OSS - API のために作られた クエリ言語 -
既存のデータに対するクエリ を実行するランタイム
GraphQL のメリット -クライアントはスキーマをもとに、 欲しいフィールドだけをリクエストできる -リレーションがある値は一度のリクエストで 取得できる -スキーマをもとに開発するので型の不一致が 起きない
GraphQL のメリット -クライアントはスキーマをもとに、 欲しいフィールドだけをリクエストできる -リレーションがある値は一度のリクエストで 取得できる -スキーマをもとに開発するので型の不一致が 起きない
GraphQL のメリット -クライアントはスキーマをもとに、 欲しいフィールドだけをリクエストできる -リレーションがある値は一度のリクエストで 取得できる -スキーマをもとに開発するので型の不一致が 起きない
REST vs GraphQL https://qiita.com/shunp/items/d85fc47b33e1b3a88167
REST vs GraphQL HTTP requests HTTP responses GET /api/user?id=1 GET
/api/address?user_id=1 { ”id” : 1, “name” : “user1” } { ”street” : “Aoba street”, “city” : “Sendai city” }
REST vs GraphQL HTTP requests HTTP responses GET /api/user?id=1 GET
/api/address?user_id=1 { ”id” : 1, “name” : “user1” } { ”street” : “Aoba street”, “city” : “Sendai city” } 2回 API を叩いてる!!
REST vs GraphQL HTTP requests HTTP responses GET /api/user?id=1 GET
/api/address?user_id=1 { ”id” : 1, “name” : “user1” } { ”street” : “Aoba street”, “city” : “Sendai city” } 2回 API を叩いてる!!
REST vs GraphQL HTTP requests HTTP responses POST /graphql query
{ user(id: 1){ id } } { ”user” : { “id”: 1, } }
REST vs GraphQL HTTP requests HTTP responses POST /graphql query
{ user(id: 1){ id name } } { ”user” : { “id”: 1, “name”: “user1” } }
REST vs GraphQL HTTP requests HTTP responses POST /graphql query
{ user(id: 1){ id name address{ street city } { ”user” : { “id”: 1, “name”: “user1”, “address”: { “street”: “Aoba street”, “city”: “Sendai city” } } }
REST vs GraphQL HTTP requests HTTP responses POST /graphql query
{ user(id: 1){ id name address{ street city } { ”user” : { “id”: 1, “name”: “user1”, “address”: { “street”: “Aoba street”, “city”: “Sendai city” } } } 1 回 API を叩くだけで良い
GitHub の repository を取ってくる REST https://api.github.com/users/Keyl0ve/repos GraphQL https://api.github.com/graphql
GitHub の repository を取ってくる REST https://api.github.com/users/Keyl0ve/repos GraphQL https://api.github.com/graphql 通信の効率は GraphQL
の方が上
GraphQL のメリット -クライアントはスキーマをもとに、 欲しいフィールドだけをリクエストできる -リレーションがある値は一度で取得できる -スキーマをもとに開発するので型の不一致が 起きない
強い型付けが採用されている - パラメータの定義には、スキーマ 定義言語(SDL)が使用されてい る - クライアントに公開されるすべて のAPIはSDLで記述されている
GraphQL のデメリット - クエリが複雑になる可能性 - クエリ伝播の問題につながるかもしれ ない - 学習の難しさ -
特にスキーマの設計
クエリ伝播の問題、スキーマ設計の難しさ query { user(id: 1){ id name address{ street city
history{ people awards{ year{ awardName personName } } sample{ sample sample sample } sample{ sample
クエリ伝播の問題、スキーマ設計の難しさ query { user(id: 1){ id name address{ street city
history{ people awards{ year{ awardName personName } } sample{ sample sample sample } sample{ sample スキーマを把握していないと、サーバー にとって非常に時間のかかる処理のクエ リを送ってしまう可能性がある
GraphQL サーバを立てよう - gqlgen を使ってサーバ 立ててみた - request から respons
まで
https://qiita.com/Keyl0ve/items/e88b83c13fb86b7c9908 GraphQL、gqlgen を使って サーバ を立てる
終わりに GraphQL、REST 使い分け の判断が重要
Thanks for listening !! Twitter: Keyl0ve_