Apollo-android: Documentation is not helpful for setting up Apollo in a non-Android environment.

Created on 5 Sep 2019  路  8Comments  路  Source: apollographql/apollo-android

The project is called apollo-android but the documentation says you can use this for a non-android setup with gradle. However, when it comes time to apply the plugin in the instructions with the sample setup, apply plugin: 'com.apollographql.android' is used.

Could non-android users get clearer documentation for setting it up in an environment that isn't android? And may I ask why is this project not taking more of an SQLDelight approach and being agnostic to the environment apart from the extra artifacts it might have and instruct you to use in their README.md?

Thanks for any help.

Documentation

Most helpful comment

@sav007 apply plugin: 'com.apollographql.android' is needed, even for non-android projects, right ?

For what it's worth, the plugin rewrite I'm working on (https://github.com/apollographql/apollo-android/pull/1507) will use com.apollographql.apollo as plugin id and deprecate com.apollographql.android. That should clear up some confusion. I'll update the PR this weekend.

Also, we should certainly rename the repo from apollo-android to something else at some point, especially with multiplatform in mind (https://github.com/apollographql/apollo-android/issues/1455). Not sure what a good name would be though. apollo-jvm doesn't work for native apollo-kotlin doesn't work with java. Maybe we should just call that graphqldelight ;)

All 8 comments

Non android users can use apollo as long as Gradle is used as build tool. There is no need to have
apply plugin: 'com.apollographql.android'

SQLDelight approach and being agnostic to the environment apart from the extra artifacts

Not sure I got the comment, but again you can use apollo outside of android projects.

https://github.com/cashapp/sqldelight

They show off SQLDelight as a general-purpose SQLite library, with compatibility for JVM and Android(and iOS because of Kotlin/Native, but this library doesn't use that). They don't purport that it is an Android-first library, and show examples for setting it up in each environment. Why does Apollo not do the same?

apply plugin: 'com.apollographql.android'

I understand this library is Android-first, but the merits of it's usage go beyond Android as well. I think it would be a wise to be a bit more agnostic of Android but show how to use it in both JVM and Android platforms, per SQLDelight's style. I'll try to throw in a pull request this weekend for documentation.

@sav007 apply plugin: 'com.apollographql.android' is needed, even for non-android projects, right ?

For what it's worth, the plugin rewrite I'm working on (https://github.com/apollographql/apollo-android/pull/1507) will use com.apollographql.apollo as plugin id and deprecate com.apollographql.android. That should clear up some confusion. I'll update the PR this weekend.

Also, we should certainly rename the repo from apollo-android to something else at some point, especially with multiplatform in mind (https://github.com/apollographql/apollo-android/issues/1455). Not sure what a good name would be though. apollo-jvm doesn't work for native apollo-kotlin doesn't work with java. Maybe we should just call that graphqldelight ;)

Really looking forward to seeing the new plugin. New id makes sense.

We've been using the Android one in non-Android module for a long time now. Works like a charm. I just needed to configure idea Gradle plugin to register the generated folder to be recognized in the idea.

I think a stand-alone sample project would be very helpful, because there are some changes needed compared to the Android sample.

In the meantime, I wrote something here that perhaps could be useful for new users: https://stackoverflow.com/questions/59776117/how-to-use-apollo-android-from-kotlin-but-without-android

@PHPirates the 'com.apollographql.apollo' plugin that you found on the gradle portal is the incubating plugin that got published there a bit early. At the moment, the 'com.apollographql.android' one on jcenter is the one to use. 'com.apollographql.apollo' will become the default in 1.3.0

The reason 'android' is used all over the place is mainly historical. Everything works without Android except 'apollo-android-support' and the espresso idling resource.

All in all, the approach is really similar to SQL delight, it's mainly the naming that's confusing. We're trying to improve this (the migration to com.apollogrphal.apollo is part of this) but it's going to take some time given the existing code.

Ah I see, thanks for the clarification! So far the only real place where 'android' appears in my project is in apply(plugin = "com.apollographql.android") and everything seems to be working correctly, so that's not too bad actually regarding the naming scheme. I'm very happy with it now, after I managed to piece together the right setup :)

I'm going to close this one as the plugin id is now com.apollographql.apollo and the current Kotlin getting-started isn't mentioning Android besides for the project name, which is harder to change for obvious reasons.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itarato picture itarato  路  3Comments

moritzmorgenroth picture moritzmorgenroth  路  4Comments

RageshAntony picture RageshAntony  路  3Comments

gmrandom picture gmrandom  路  4Comments

pratthama-appdesk picture pratthama-appdesk  路  3Comments