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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuta Tomiyama
August 19, 2023
Programming
210
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
520
モバイルアプリ開発を始めよう!
yt8492
0
130
Git勉強会
yt8492
0
240
なんでもやってみる勇気
yt8492
0
140
Android Autoが思ったよりしんどい話
yt8492
0
260
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
1.1k
今だからこそ知りたいKotlin Multiplatform
yt8492
0
360
State management and API calls in Jetpack Compose: Learning Apollo + Jetpack Compose through React Hooks
yt8492
0
1.4k
サーバーフレームワークの仕組みが気になったので車輪の再発明をしてみた
yt8492
0
270
Other Decks in Programming
See All in Programming
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
170
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
3
630
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
140
sbt 2.0: takeoff
eed3si9n
0
180
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
310
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
140
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
210
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
1.6k
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
320
オーケストレーション記述言語 Katari
yukikurage
0
210
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
120
Spec-driven Development with AI
simas
PRO
0
2.2k
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
A Modern Web Designer's Workflow
chriscoyier
699
190k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
Side Projects
sachag
456
43k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
340
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
340
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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コントリビュート、しよう!