I'm trying to integrate an apollo client into a mp...
# apollo-kotlin
s
I'm trying to integrate an apollo client into a mp project - jvm/js - but building it fails due to a lot of unresolved reference errors in the generated code.
build\generated\source\apollo\service\com\example\type\GraphQLBoolean.kt: (8, 12): Unresolved reference: apollographql
however, intellij shows those files are just fine. any dependencies other than
implementation("com.apollographql.apollo3:apollo-runtime:3.6.0")
I need to add somewhere?
m
This is very weird... Maybe try
Copy code
implementation("com.apollographql.apollo3:apollo-api:3.6.0")
But I'd expect that one to be transitively included...
If that doesn't make it, can you share the full stacktrace?
Copy code
./gradlew build --stacktrace
s
here it is https://pastebin.com/m43Hw5Bc api dep did not help unfortunately
m
Taht is very weird. did you add it in the commonMain sourceSet?
Copy code
kotlin {
  sourceSets {
    val commonMain by getting {
      depenencies {
        implementation("com.apollographql.apollo3:apollo-runtime:3.6.0")
      }
    }
  }
}
Other things I would look for is IR vs legacy and Kotlin versions (I'd recommend IR + 1.7.10)
s
yes, by now it's actually in all three source sets
I have to see if I can tweak the versions a bit but my options are very limited here
due to some conflicts with ktor and compose
m
What version of Kotlin are you on?
If you can share a reproducer, I'll look into it
s
1.6.10
I'll try to make one
m
And if you can, I'd try upgrading to 1.7. Kotlin multiplatform moves fast. Judging by what you say, it sounds like the IDE is using the 1.7 plugin but not the CLI
There could be something in 1.6.10 that's not supported (not sure but that could be a thing)
s
mp might move fast but compose doesn't, that's the issue. think 1.7.10 support is only alpha for now. or even everything above 1.6.10 I think
https://github.com/TheDome0/ktapolloissues I just set up a project with the compose for web library I use and added apollo - exact same issue I'm getting in the other one
m
Thanks for providing this, looking into it
What should I run to have the error? I currently get this:
Copy code
$ ./gradlew build

> Configure project :
Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.


FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':kotlinNodeJsSetup'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
   > Could not find node-14.17.0-darwin-arm64.tar.gz (org.nodejs:node:14.17.0).
     Searched in the following locations:
         <https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-arm64.tar.gz>
s
uh that's also new to me
m
Ah, I'm on an M1
That must be the explanation...
s
seems like it. apparently 1.6.20 might fix it
m
TBH, I'd consider bumping to 1.7.10, it might solve a lot of these issues
s
yes Ik but lib dev of doesn't fancy the alpha versions of compose. though I also have to use ktor 2.0.0-beta-1 because of it
I'll have a look at a pure compose for web project for both versions and see if I"m getting the same error and if so - if 1.7.10 fixes is
m
Isn't there a stable compose version for 1.7.10 these days? https://developer.android.com/jetpack/androidx/releases/compose-kotlin
s
android but not desktop/web afaik (which is maintained by jetbrains)
m
ah, I see
s
alright. 1.6.10 doesn't seem to work at all but 1.7.10 with an alpha version of compose works
edit: adding the dependency to commonMain makes intellij happy but still no luck with building it
m
Reproduced in docker. You can downgrade apollo to 3.5.0 and it'll work with Kotlin 1.6
Looks like JS has the same issue as native where there's no forward compatibility
(we started using 1.7 with 3.6.0, it was using 1.6 before that)
s
by doing so I run into
java.lang.IllegalArgumentException: Sequence has more than one element.
m
At runtime or build time?
ok build time
s
it's same as this https://youtrack.jetbrains.com/issue/KT-52047 fixed with 1.6.20
m
compileProductionExecutableKotlinJs
That's not related to Apollo
s
ye but also fixed with upgrading to 1.6.20
m
Looks like Kotlin 1.6.20 + Apollo 3.5.0 is your sweet spot 😅
I asked the question about JS compiler forward compatibility there if you're interested in followingup: https://kotlinlang.slack.com/archives/C0B8L3U69/p1662918780114269
s
haha yeah let's hope I can make it happen in this dependency hell
Uncaught Error: Error loading module 'ktapolloissues'. Its dependency 'kotlin_kotlin' was not found. Please, check whether 'kotlin_kotlin' is loaded prior to 'ktapolloissues'.
blob upside down
m
😬
e
FYI your Compose compiler plugin version Compose runtime version don't need to match