Upgrade to Pro — share decks privately, control downloads, hide ads and more …

入門Hasura

ryo
December 05, 2019

 入門Hasura

もくテク #4 冬のLT大会

ryo

December 05, 2019
Tweet

More Decks by ryo

Other Decks in Technology

Transcript

  1. 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}", . . 以下略
  2. 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}", . . 以下略 大量の不要なカラムも 取得してしまう
  3. { user(login: “username”) { name repositories { totalCount } }

    } GraphQL Request POST https://api.github.com/graphql
  4. { "data": { "user": { "name": "ryo", "repositories": { "totalCount":

    106 } } } } GraphQL Respose 必要なリソースのみ 宣言的に取得出来る
  5. { user(login: “username”) { followers { totalCount nodes { name

    followers { totalCount } } } } } GraphQL Request
  6. { user(login: “username”) { followers { totalCount nodes { name

    followers { totalCount } } } } } GraphQL Request 一つのリクエストで 関連のデータまでまとめて 取得出来る
  7. • ネストした関連データの取得 • 集計処理(count, sum, avg, max, min) • フィルター処理(eql,

    pattern match) • 並び替え • ページネーション • トランザクションでの更新 • カスタムSQL関数を含むクエリ ...etc