https://kotlinlang.org logo
#apollo-kotlin
Title
# apollo-kotlin
e

Elliot Murray

12/11/2023, 12:30 PM
Hey 👋 I'm trying to do an implementation similar to the one discussed in this comment, where we have a
debug
endpoint and a
release
endpoint and have a service set up for each. Each schema is then downloaded to a separate source set location, and the queries are in the
main
source set, so shared with both variants. The idea here is the debug schema can be updated (e.g. a new field has been added) before the release schema, and I can update the queries to include this new field. Ideally then I'd like the debug version to still compile, but the release to fail due to the missing field, until that change is pushed to the release endpoint/the release schema is updated also. The issue I'm seeing with this however, is when I build the debug version the
generateReleaseApolloSources
task is also run, and that fails the build because the field doesn't exist yet in the release schema. Is there any way around this issue? I'm new to GraphQL so appreciate I may be aiming at the incorrect solution here! Thanks 🙂
1
m

mbonnin

12/11/2023, 12:33 PM
when I build the debug version the
generateReleaseApolloSources
task is also run
Welp, that's unexpected 🤔 . Can you try
./gradlew assembleDebug -m
?
e

Elliot Murray

12/11/2023, 12:37 PM
Yeah so turns out I lied 😅 that works fine, it's complaining during project sync 🤔
m

mbonnin

12/11/2023, 12:38 PM
Ah yea, that could happen
I'am assuming you selected "debug" as the build variant in the IDE?
Screenshot 2023-12-11 at 13.39.43.png
(that's just a sample)
e

Elliot Murray

12/11/2023, 12:41 PM
Yeah, seems to try run all of the generatexApolloSources tasks
m

mbonnin

12/11/2023, 12:42 PM
There's a setting that runs the
generateXyz()
task automatically, let me check
s

Stylianos Gakis

12/11/2023, 12:43 PM
Could this
generateSourcesDuringGradleSync.set(false)
help in this case?
🎯 1
m

mbonnin

12/11/2023, 12:44 PM
Exactly!
e

Elliot Murray

12/11/2023, 12:45 PM
That did it! I presume the only downside of this is I'd need to build first to get the generated sources (which is totally fine)
nod 1
m

mbonnin

12/11/2023, 12:45 PM
generateSourcesDuringGradleSync
is removed in v4 though because the IDE plugin makes it automagically (and I don't think there's a proper solution there besides removing the IJ plugin altogether 🤔 )
e

Elliot Murray

12/11/2023, 12:47 PM
Yeah I know nothing about v4 😅 does that translate to "you may have issues when upgrading to v4"?
m

mbonnin

12/11/2023, 12:49 PM
Roughly speaking yes 😅 . I meant this as an issue for us for the time being so hopefully you don't have an issue 🙂
FWIW, the issue (if there's one) is mainly with the IJ plugin so it's not like it's going to break your v3 code. It's more that it'd be nice for the IJ plugin to support that use case
e

Elliot Murray

12/11/2023, 12:57 PM
Ah do you mean v4 doesn't generate during gradle sync anymore, which is basically the same as setting
generateSourcesDuringGradleSync
to false in v3?
m

mbonnin

12/11/2023, 1:00 PM
Exactly, v4 relies on an Android Studio plugin for IDE integration
An the Android Studio plugin calls
generateSources
by default IIRC
Not sure what happens one service fails, we should double check that
e

Elliot Murray

12/11/2023, 1:03 PM
Cool, I'll let future me worry about this issue if it ever turns into one 😅, thanks for your help and let me know if you want me to test anything with v4 and this use case 🙂
thank you color 1
👍 1
b

bod

12/11/2023, 2:31 PM
(The IJ plugin ignores codegen fails)
🙌 2
4 Views