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
入門Hasura
Search
ryo
December 05, 2019
Technology
2.9k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
入門Hasura
もくテク #4 冬のLT大会
ryo
December 05, 2019
More Decks by ryo
See All by ryo
Bridging Social Graphs
kawamataryo
0
340
Raycast AI APIを使ってちょっと便利なAI拡張機能を作ってみた
kawamataryo
1
600
退屈なことはDevinにやらせよう〜〜Devin APIを使ったVisual Regression Testの自動追加〜
kawamataryo
5
2.3k
SaaS公式MCPサーバーをリリースして得た学び
kawamataryo
7
2.2k
Raycast AI APIを使ってちょっと便利な拡張機能を作ってみた / created-a-handy-extension-using-the-raycast-ai-api
kawamataryo
1
900
ts-morphのパフォーマンス改善Tips
kawamataryo
0
140
webpack to Rspack
kawamataryo
0
140
GitHub Actions と Datadog でコードベースの定点観測
kawamataryo
7
2.1k
個人開発駆動学習 / personal development driven learning
kawamataryo
1
320
Other Decks in Technology
See All in Technology
生成AI時代の クレデンシャルとパーミッション設計
nrinetcom
PRO
4
1.6k
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
130
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
240
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
120
スクラムで身についていた動き方を、XPで捉え直してみた
codmoninc
PRO
1
290
2026/09/10 Spring_Bootから_Jakarta_EE_MicroProfileへの移行
megascus
0
210
Bet AI Day 2026丨バクラク Autopilot、業務システムの再設計
layerx
PRO
2
1.6k
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
240
Autonomous AI Databaseサービス・アップデート(FY27)/ adb-service-update-jp-fy27
oracle4engineer
PRO
0
130
Self Healing Rollouts: Automating Production Fixes with Agentic AI
kdubois
0
160
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
530
DINO-EdgeQuery:Edge-First Polygon Decoding for Building Footprint Extraction from Satellite Imagery
lehupa
0
160
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
690
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
370
The Curious Case for Waylosing
cassininazir
1
500
Designing Experiences People Love
moore
143
24k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Odyssey Design
rkendrick25
PRO
2
800
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
The Invisible Side of Design
smashingmag
301
52k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Transcript
入門 Hasura 〜 HasuraでサクッとGraphQL 体験 〜 @RyoKawamata
自己紹介
@RyoKawamata 消防士歴 6年半, エンジニア歴 1年半 株式会社Misoca リモートワーク@茨城
今日話すこと
GraphQLの簡単な紹介 Hasuraで出来ること・出来ないこと
GraphQL とは何か?
API向けの問い合わせ言語・仕様
問い合わせ言語?
APIを対象にしたSQL的なもの
あるユーザーの 名前、会社名、URLを取得したい example
SELECT name, company, url FROM users WHERE id = '1234'
SQL DB
SQL DB name compony url ryo misoca misoca.jp
query getUser { user(id: ‘1234’) { name company url }
} GraphQL API Server
“data” { ”user” { “name”: “ryo” “company”: “misoca” “url”: “misoca.jp”
} } GraphQL API Server
• 必要なものを必要な分だけ取得できる • 単一のエンドポイント • 強力な型システムを持つ feature
REST API の課題とGraphQL
過剰な取得 必要のないデータまで まとめて取得してしまう
example ユーザーの名前とリポジトリ数を取得したい
REST Request GET https://api.github.com/users/${ username }
REST Response { "login": "kawamataryo", "id": 11070996, "node_id": "MDQ6VXNlcjExMDcwOTk2", "avatar_url":
"https://avatars1.githubusercontent.com/u/11070996?v=4", "gravatar_id": "", "public_repos": 95, "public_gists": 0, "followers": 8, "following": 7, "url": "https://api.github.com/users/kawamataryo", "html_url": "https://github.com/kawamataryo", "followers_url": "https://api.github.com/users/kawamataryo/followers", "following_url": "https://api.github.com/users/kawamataryo/following{/other_user}", "gists_url": "https://api.github.com/users/kawamataryo/gists{/gist_id}", . . 以下略
REST Response { "login": "kawamataryo", "id": 11070996, "node_id": "MDQ6VXNlcjExMDcwOTk2", "avatar_url":
"https://avatars1.githubusercontent.com/u/11070996?v=4", "gravatar_id": "", "public_repos": 95, "public_gists": 0, "followers": 8, "following": 7, "url": "https://api.github.com/users/kawamataryo", "html_url": "https://github.com/kawamataryo", "followers_url": "https://api.github.com/users/kawamataryo/followers", "following_url": "https://api.github.com/users/kawamataryo/following{/other_user}", "gists_url": "https://api.github.com/users/kawamataryo/gists{/gist_id}", . . 以下略 大量の不要なカラムも 取得してしまう
{ user(login: “username”) { name repositories { totalCount } }
} GraphQL Request POST https://api.github.com/graphql
{ "data": { "user": { "name": "ryo", "repositories": { "totalCount":
106 } } } } GraphQL Respose
{ "data": { "user": { "name": "ryo", "repositories": { "totalCount":
106 } } } } GraphQL Respose 必要なリソースのみ 宣言的に取得出来る
過小な取得 必要な情報によっては 複数回のリクエストを組み合わ せる必要がある。 (関連まで取りたい場合など)
example あるユーザーのフォロワー数と、 そのフォロワーのフォロワー数を取得したい
REST GET https://api.github.com/users/${ username }/followers でフォロワーを取得 さらにフォロワーの数だけ、同じリクエストを投げ て、全ての結果をカウントする。
REST GET https://api.github.com/users/${ username }/followers でフォロワーを取得 さらにフォロワーの数だけ、同じリクエストを投げ て、全ての結果をカウントする。 複数回のリクエストの 統合が必要
{ user(login: “username”) { followers { totalCount nodes { name
followers { totalCount } } } } } GraphQL Request
{ user(login: “username”) { followers { totalCount nodes { name
followers { totalCount } } } } } GraphQL Request 一つのリクエストで 関連のデータまでまとめて 取得出来る
つまり
GraphQL 最高便利..!!!
でも..
サーバーサイドの実装大変そう、、 自由に取れるってセキュリティ大丈夫?? そもそもAPI変えるほどの工数ない
大丈夫!!!
Hasura がある!!
Hasuraとは?
PostgreSQLのTableスキーマから GraphQLのAPIを自動生成するもの
None
DEMO
Hasuraの良いところ
CRUD・Subscription のクエリを自動で提供してくれる Pross
• ネストした関連データの取得 • 集計処理(count, sum, avg, max, min) • フィルター処理(eql,
pattern match) • 並び替え • ページネーション • トランザクションでの更新 • カスタムSQL関数を含むクエリ ...etc
テーブルのカラム単位で 操作の認可を設定できる Pross
None
Firebase, Auth0
Event Trigger・Remote Schema で柔軟なAPIも構築可能 Pross
Event Trigger 指定されたテーブルのイベントをトリガーに Webhookを呼び出してカスタムロジックを実行する機能
Remote Schema 独自に実装した GraphQLサーバーを Hasuraのエンドポイ ントにマージして利用 可能にする機能
Hasuraを使う上での注意
クエリに対するValidationが まぁまぁきつい Cons
PostgreSQLのTriggerで実行 or 別にGraphQL サーバーを立てて Remote Schema実行
まとめ
Hasuraは便利なものの 全てを解決すことはできない。 ただ、他サービスと上手く連携し作り上げられ れば、GraphQL APIサーバー構築の工数を大 幅に下げられる可能性はある
参考
O`REILLY 初めてのGraphQL ~ WEBサービスを作って学ぶ次世代API~ 定価 2,860 円