Apollo-android: Gson vs Moshi

Created on 11 May 2017  Â·  6Comments  Â·  Source: apollographql/apollo-android

Is there any reason appollo-runtime is bringing in a dependency on Moshi? Is there a possibility that we could switch it to Gson?

Most helpful comment

For now the benefit of removing Moshi are 535 methods, that don't think too much overhead. So for now this is not an issue. Closing

All 6 comments

moshi is used for serializing GraphQL operation variables.
What the reason of switching to Gson?

@sav007 I am just curious if there is away to abstract that out similar to how Retrofit does it. This way consumers can choose whether they want to use Moshi or Gson.

For instance, existing Android applications that are using GSON or Jackson, will now have to include Moshi as a transitive dependency from Apollo.

Apollo client is slightly different from Retrofit.

There is no point to allow user to select the JSON serializer library as it will be used for only one case: serializing variables.

Parsing GraphQL JSON response is done via generated code without using any library.

So Moshi lib is used for internal needs only and it's really small library. Plus if you switch your client over to GraphQL that means probably you migrate from REST to GraphQL, that means from Retrofit. So you probably won't have any other JSON library as you don't need them any more for GraphQL.

Anyway we will probably replace Moshi internally with JsonWriter.

My concern is an app is now forced to consume another Jain parsing library,
which further increases the method counts.

On May 11, 2017 4:27 PM, "Ivan Savytskyi" notifications@github.com wrote:

Apollo client is slightly different from Retrofit.

There is no point to allow user to select the JSON serializer library as
it will be used for only one case: serializing variables.

Parsing GraphQL JSON response is done via generated code without using any
library.

So Moshi lib is used for internal needs only and it's really small
library. Plus if you switch your client over to GraphQL that means probably
you migrate from REST to GraphQL, that means from Retrofit. So you probably
won't have any other JSON library as you don't need them any more for
GraphQL.

Anyway we will probably replace Moshi internally with JsonWriter.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/apollo-android/issues/487#issuecomment-300943361,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABqMSJA3Adb-R34WXg9JKcgP4AJp3bD2ks5r45lNgaJpZM4NXXQw
.

Method count for moshi lib is: 535

For now the benefit of removing Moshi are 535 methods, that don't think too much overhead. So for now this is not an issue. Closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vikrama picture vikrama  Â·  3Comments

john-lanticse picture john-lanticse  Â·  3Comments

k-misztal picture k-misztal  Â·  3Comments

TayfunCesur picture TayfunCesur  Â·  4Comments

gmrandom picture gmrandom  Â·  4Comments