https://kotlinlang.org logo
Title
v

Volodymyr Korniienko

02/18/2022, 9:20 AM
hi! I’m migrating to apollo kotlin v3 and I need to make a decision between 
responseBased
 and 
operationBased
 codegen. 
responseBased
 is claimed to be more performant but generates tons of code that may affect class loading and compilation time. Therefore I’m wondering is there any performance analysis of these two methods based on response size/nested fragments count/any other metric?
m

mbonnin

02/18/2022, 9:20 AM
Sadly not at this point.
It depends a lot how you use fragments and merged fields
One thing to note is that while class loading might be slower, parsing with
responseBased
models is faster because they can stream the response
So it's all a tradeoff really.
My rule of thumb there is that
operationBased
is more predictable and will give stable performance so it's a good default to start with.
responseBased
will give you more type information and parsing speed but it also comes with gotchas so it's a good thing to explore once you're comfortable with
operationBased
👍 1
v

Volodymyr Korniienko

02/18/2022, 9:27 AM
Thank you Martin, will proceed with
operationBased
then.
👍 1
m

mbonnin

02/18/2022, 9:28 AM
Let us know how that goes! I've been wanting to write benchmark for this but benchmarking is hard and I think any meaningful comparison will need to be on a real-life codebase. If you ever end up trying
responseBased
, let me know how that works, we can add that to the docs somewhere
👌 1
y

Yang

02/18/2022, 1:33 PM
I use responsedBased with flattenModels.set(true) which has been working quite well in a KMM project
🎉 3