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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
260
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
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
160
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
490
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
130
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
130
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
21
21k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
360
ジョジョの世界をXRで再現する
mofurune
0
140
phperだってパンチカードでコーディングしたい
o0h
PRO
0
230
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
450
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
mrbgem 三角測量 開発
ogom
0
210
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.2k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
699
190k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
Mind Mapping
helmedeiros
1
390
Practical Orchestrator
shlominoach
192
12k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
490
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
370
The SEO identity crisis: Don't let AI make you average
varn
0
580
Making the Leap to Tech Lead
cromwellryan
135
10k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
KATA
mclloyd
PRO
35
16k
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コントリビュート、しよう!