Apollo-android: Manage importing fragments from different modules into a single query

Created on 6 Feb 2020  路  4Comments  路  Source: apollographql/apollo-android

Is your feature request related to a problem? Please describe.
We have a query (in module 3) that has fragments from different modules and want to be able to combine into one query.

query {
  User {
    section {
      ...SharedUserFragment #(from module 1)
      ...PaidUserFragment #(from module 2)
    }
  }
}

Describe the solution you'd like
I hope to be able to import the fragments from different modules into a single query. This is related to https://github.com/apollographql/apollo-android/issues/593 and https://github.com/apollographql/apollo-android/issues/1008

gradle-plugin In Progress Feature

Most helpful comment

@Jawnnypoo thanks for looking into this!

There is a great discussion in the iOS repo. I'm not sure how much of that would apply to Android. Especially, I'm not sure Android needs a separate ApolloConfig.json since a lot of that logic could be added directly in the Gradle plugin.

Ideally, I think this could even be a "no configuration" thing, just adding another module as a dependency with implementation(project(":commonModule")) could pull the appropriate fragments and custom types, adapters, configuration, etc... automagically. But I definitely didn't look very close there so there might be a lot of caveats !

All 4 comments

Do we know if there have been any attempts at this? I am potentially going to look into this and was curious if there is any additional info on how it can be done.

@Jawnnypoo thanks for looking into this!

There is a great discussion in the iOS repo. I'm not sure how much of that would apply to Android. Especially, I'm not sure Android needs a separate ApolloConfig.json since a lot of that logic could be added directly in the Gradle plugin.

Ideally, I think this could even be a "no configuration" thing, just adding another module as a dependency with implementation(project(":commonModule")) could pull the appropriate fragments and custom types, adapters, configuration, etc... automagically. But I definitely didn't look very close there so there might be a lot of caveats !

The branch I'm using to investigate this: https://github.com/apollographql/apollo-android/pull/2514
It's working modulo a lot of edge cases but the general direction should be there, let me know what you think.

2.4.0 is now released with experimental multi-modules support. Please try it out and let open new issues if needed before we remove the @ApolloExperimental annotation down there, most likely by the end of this year.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RageshAntony picture RageshAntony  路  3Comments

vikrama picture vikrama  路  3Comments

doums picture doums  路  3Comments

TayfunCesur picture TayfunCesur  路  4Comments

sav007 picture sav007  路  4Comments