Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
apollo-kotlinにcontributeした話
Search
Yuta Tomiyama
August 19, 2023
Programming
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
apollo-kotlinにcontributeした話
2023/08/19 TOGATTA SERVER LT #3 にて発表
Yuta Tomiyama
August 19, 2023
More Decks by Yuta Tomiyama
See All by Yuta Tomiyama
ビルドプロセスをデバッグしよう!
yt8492
2
510
モバイルアプリ開発を始めよう!
yt8492
0
130
Git勉強会
yt8492
0
240
なんでもやってみる勇気
yt8492
0
140
Android Autoが思ったよりしんどい話
yt8492
0
250
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
1k
今だからこそ知りたいKotlin Multiplatform
yt8492
0
350
State management and API calls in Jetpack Compose: Learning Apollo + Jetpack Compose through React Hooks
yt8492
0
1.4k
サーバーフレームワークの仕組みが気になったので車輪の再発明をしてみた
yt8492
0
260
Other Decks in Programming
See All in Programming
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
130
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
200
速習iPhone Duo対応
yuukiw00w
2
730
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
390
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
120
すこし踏み込む CancellationToken
htkym
2
980
Intent as Code
shoppingjaws
6
1.1k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
iOSDC2026登壇資料.pdf
riofujimon
0
180
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
660
setup-vp GitLab対応の裏側
naokihaba
0
120
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
280
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
920
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Mobile First: as difficult as doing things right
swwweet
225
10k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
Bash Introduction
62gerente
615
220k
30 Presentation Tips
portentint
PRO
1
400
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
710
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Transcript
apollo-kotlinに contributeした話 2023/08/19 TOGATTA SERVER LT
自己紹介 HN: マヤミト 本名: 富山雄太 GitHub: https://github.com/yt8492 趣味: Kotlin, Twitter,
同人作品 会津大卒 Androidエンジニア Twitter: yt8492
近況報告
薄い本を売ったり買ったりしてました
本題
OSSコントリビュートしてました
apollo-kotlinとは? • Kotlin向けGraphQLクライアントライブラリのデファクトスタンダード • GraphQLのサーバーとの通信やキャッシュ管理をいい感じにやってくれる • KMP対応 • 機能ごとにモジュールが分けられている(コア、ランタイム、キャッシュなど)
元々あった実装 • apollo-runtimeにはEngineのinterfaceが定義されている ◦ interfaceをimplementsすればカスタムのEngineを実装することができる • apollo-kotlinには元々デフォルトで使われるEngineが提供されている ◦ DefaultHttpEngine ◦
DefaultWebsocketEngine • DefaultEngineもKMP対応しているが、実装自体は分かれている ◦ class宣言はexpectでcommonモジュールで型の宣言だけしている ◦ 実装はactualでJVM, JS, Apple(iOS, MacOS)で分けられている ▪ JVMはOkHttp ▪ JSはKtor ▪ AppleはNSURLSession
common(expect) - DefaultHttpEngine - DefaultWebsocketEngine jvm(actual) apple(actual) js(actual) - OkHttp
- Ktor - NSURLSession
元々あった実装 • apollo-runtimeにはEngineのinterfaceが定義されている ◦ interfaceをimplementsすればカスタムのEngineを実装することができる • apollo-kotlinには元々デフォルトで使われるEngineが提供されている ◦ DefaultHttpEngine ◦
DefaultWebsocketEngine • DefaultEngineもKMP対応しているが、実装自体は分かれている ◦ class宣言はexpectでcommonモジュールで型の宣言だけしている ◦ 実装はactualでJVM, JS, Apple(iOS, MacOS)で分けられている ▪ JVMはOkHttp ▪ JSはKtor ▪ AppleはNSURLSession → Ktorを使えばcommonに全部実装共通化できるんじゃね?
common - KtorHttpEngine - KtorWebsocketEngine
今回やったこと • Ktorを使ったKMP対応のApolloのEngineを実装した ◦ KtorHttpEngine ◦ KtorWebsocketEngine • ↑を含んだ新しいapollo-kotlinのモジュールを追加した ◦
apollo-engine-ktor
手順 1. commonMainなKtorのEngineを実装する 2. commonTestに実装したKtorのEngineのテストを書く 3. JVM, JS, Appleでそれぞれ同じテストが通るか確認する
Q. 難しいんでしょう?
Q. 難しいんでしょう? A. 意外と簡単です Engine自体はただApollo側で定義されたHTTP/Websocketのリクエストをそれぞれ のEngineの形式のものに変換して実行し、レスポンスをApolloのものに変換して返す だけ
HttpEngineのinterface
KtorHttpEngine
HttpEngineがリクエストを処理するまで 1. ApolloClient.BuilderにHttpEngineが渡される 2. HttpNetworkTransport.BuilderにHttpEngineが渡される 3. ApolloClientのプロパティのNetworkInterceptorにHttpNetworkTransportが 渡される 4. リクエスト実行時にApolloClientが持つinterceptersが順番にリクエストを処理
し、最後にNetworkInterceptorの処理が走るのでそのタイミングでHttpEngine が呼び出される
感想 • デカいOSSに貢献できてうれち〜〜〜〜〜〜〜〜〜〜 • プルリクのコメントで結構いろいろ教えてくれてやりやすかった • みんなもOSSコントリビュート、しよう!