GraphQL
https://gyazo.com/637324c63a3adf4a254626d08802acba
もともとはFacebookが出している、「API自体」の仕様
今はGraphQL Foundationに移管された
のっとって実装すると、柔軟なクエリが書けるようになる
主な利用者
Facebook, Airbnb, Atlassian, Audi, CNBC, Major League Soccer, Netflix, Shopify, The New York Times, Twitter, Pinterest, Yelp...
GitHubはAPI v4からGraphQLに移行
GitHub GraphQL API v4 | GitHub Developer Guide
資料
Introduction to GraphQL | GraphQL
公式
エンジニアHubに『「GraphQL」徹底入門』という記事を寄稿しました - Islands in the byte stream(2018-12-26)
まとまっていて、2019-02-07時点でこれを一番始めによむとよさそうkadoyau.icon
GraphQL入門 - 使いたくなるGraphQL - Qiita
DroidKaigi 2018で『すばらしきGraphQLのSEKAIへようこそ』という発表をしました - Islands in the byte stream
クライアント視点
「リソース取得に特化した Web API」
サーバ視点
RejectKaigi 2017で「GraphQL on Rails」という発表をしました - Bit Journey's Tech Blog
dex.fm — 049: GraphQL PartⅠ #dex.fm
「うまく設計されたREST APIなら同じことはできる」
dex.fm — 050: GraphQL PartⅡ
GraphQLを主要FWや言語で上手く使うためのライブラリ群Apolloの話題
Apollo GraphQL
Rebuild: 193: Winter Is Coming (gfx) #Rebuild
Introducing the GraphQL Guide – The GraphQL Guide by John Resig
Episode 12 – Semantics and Complexity of GraphQL – Misreading Chat #Misreading_Chat
RESTより指数関数的に負荷のかかるクエリ(「AのもつすべてのBのもつすべてのC」みたいなの)を書きやすいので、オープンなAPIを作成する際には盲点があるかも
/graphql-ruby-ja/GraphQLは内部API向きか外部API向きか
双方向通信の規定がないのでsubscriptionは頑張りが必要
Notes on GraphQL for Ruby
運用知見
GraphQL Summit 2018 に参加してきました - Mercari Engineering Blog
書籍
https://www.oreilly.co.jp/books/9784873118932/
利点
REST vs GraphQL APIs, the Good, the Bad, the Ugly - DEV Community 👩‍💻👨‍💻
Some APIs such as those with very few entities and relationships across entities like analytics APIs may not be suited for GraphQL. Whereas applications with many different domain objects like e-commerce where you have items, users, orders, payments, and so on may be able to leverage GraphQL much more.
https://www.apollographql.com/docs/tutorial/introduction.html
Why do you need a graph? Today, one of the most difficult parts of building an app is figuring out your data layer. Often, there’s many data sources you need to fetch from and many clients you need to support. When you layer a graph in between your services and your UI, you can remove a lot of complexity from your data fetching logic and ship features faster.
Rebuild: 193: Winter Is Coming (gfx)
考えることがRESTより少ない(gfx)
RESTの5つに当てはまらないものどうするの問題
「DELETEと言っても削除はせず単なるアーカイブである」とか
どちらが正しいのか問題を繰り広げてしまう
GraphQLなら適切な単語を付ける事ができる
リソース同じなのに呼び出しユーザの名前とかが入るとキャッシュがきかないのでつらい(miyagawa)
利用例
2021/08/23 メルカリShops のフロントエンド | メルカリエンジニアリング
Apollo
新規プロダクトに GraphQL を導入した感想を、バックエンドエンジニアに聞いてみた - work plus ~これからの「働く」が豊かになるメディア~
Episode 14 – LevelDB – Misreading Chat #Misreading_Chat
ラスト5分程度でAirBnBでの活用例が話されている
Reconciling GraphQL and Thrift at Airbnb – Airbnb Engineering & Data Science – Medium
https://gyazo.com/6e674bb63200223dd261142004a0cf12
用語集
GraphQLの基本用語 - Islands in the byte stream
開発ツール
graphql/graphiql: An in-browser IDE for exploring GraphQL.
IDE。Swagger UIのようなもの。
チュートリアル
Fullstack Tutorial with GraphQL, React & Apollo
RelayはApolloより学習コストが高い
#API