agrosner
03/06/2023, 5:05 PMdebug
source sets, and then consume it in debug
directories only and have apollo generate debug only sources? use case we want to include mock schema in our app without needing to introspect a local mock server but want to ensure it doesnt leak into productionapollo {
service("service") {
outputDirConnection {
connectToAndroidSourceSet("demoDebug")
}
}
}
Marco Pierucci
03/06/2023, 5:06 PMagrosner
03/06/2023, 5:06 PMMarco Pierucci
03/06/2023, 5:07 PMagrosner
03/06/2023, 5:09 PMMarco Pierucci
03/06/2023, 5:13 PMagrosner
03/06/2023, 7:45 PMcreateAllAndroidVariantServices
seems to do the trick.mbonnin
03/06/2023, 8:51 PMcreateAllAndroidVariantServices
does work. Heads up it's running a different codegen instance for each of your variants.apollo {
service("release") {
schemaFile.set(releaseSchemaFile)
srcDir(operationFiles)
outputDirConnection {
connectToAndroidSourceSet("release")
}
}
service("debug") {
schemaFile.set(debugSchemaFile)
# Reuse the main source files
srcDir(operationFiles)
# And add some debug only
srcDir(debugOnlyOperationFiles)
outputDirConnection {
connectToAndroidSourceSet("debug")
}
}
}
agrosner
03/06/2023, 9:23 PMsrc / main / graphql
-> api1
-> schema.graphqls, operations.graphl, etc
-> api2
src / debug / graphql
-> api1
-> mock_extra_schema.graphqls + schema.graphqls, operations.graphql, etc
extend type
on main schema for development ahead of production inclusionmbonnin
03/06/2023, 9:32 PMwith debug inheriting all of the stuff from api / main, including scalars etc. but providing extra schema andAre your api1Debug and api1Release .graphql files the same or are they different too?on main schema for development ahead of production inclusionextend type
agrosner
03/06/2023, 9:34 PMsrc/debug/graphql
if theyre using any operations or fields defined from the src/debug/graphql
of the schema modulembonnin
03/06/2023, 9:35 PMagrosner
03/06/2023, 9:35 PMmain
generated for both debug and release (or just in normal output)mbonnin
03/06/2023, 9:35 PMagrosner
03/06/2023, 9:35 PMapi1
debugApi1 extends api1
releaseApi1 extends api1
api2
all as service configurations. where they inherit from base api
or whateveroutputDirConnection
mbonnin
03/06/2023, 9:38 PMagrosner
03/06/2023, 9:39 PMmbonnin
03/06/2023, 9:40 PMour consuming modules that use debug only operationsthat use debug only fragments, right?
agrosner
03/06/2023, 9:40 PMmbonnin
03/06/2023, 9:49 PM// schema/build.Gradle.kts
apollo {
service("api1Release") {
schemaFile.set(file("src/release/graphql/api1/schema.graphqls"))
srcDir("src/main/graphql")
outputDirConnection {
connectToAndroidSourceSet("release")
}
}
service("api1Debug") {
schemaFiles.set(files("src/release/graphql/api1/schema.graphqls", "src/debug/graphql/api1/extra.graphqls"))
srcDir("src/main/graphql")
outputDirConnection {
connectToAndroidSourceSet("debug")
}
}
// Same for api2Release and api2Debug
}
agrosner
03/06/2023, 9:50 PMmbonnin
03/06/2023, 9:56 PMagrosner
03/06/2023, 10:23 PMbuild/generated/usedCoordinates/apollo/api1Debug/usedCoordinates.json (No such file or directory)
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache state could not be cached: field '__alwaysGenerateTypesMatching__' from type 'com.apollographql.apollo3.gradle.internal.ApolloGenerateSourcesTask': error writing value of type 'org.gradle.api.internal.provider.DefaultSetProperty'
> java.io.FileNotFoundException: /**/**-graphql/build/generated/usedCoordinates/apollo/api1Debug/usedCoordinates.json (No such file or directory)
at okio.Okio__JvmOkioKt.source(JvmOkio.kt:182)
at okio.Okio.source(Unknown Source)
at com.apollographql.apollo3.compiler.ApolloUsedCoordinatesKt.toUsedCoordinates(ApolloUsedCoordinates.kt:25)
at com.apollographql.apollo3.gradle.internal.DefaultApolloExtension$registerCodeGenTask$1.invoke$lambda$15(DefaultApolloExtension.kt:741)
at org.gradle.api.internal.provider.DefaultProvider.calculateOwnValue(DefaultProvider.java:72)
mbonnin
03/07/2023, 7:25 PMagrosner
03/07/2023, 7:26 PMapp
mbonnin
03/07/2023, 7:27 PMassembleDebug
?agrosner
03/07/2023, 7:27 PMgenerateApolloSources
was doing it. we have that run prior to using our wrapper tasksmbonnin
03/07/2023, 7:29 PMassembleDebug
to run all the tasks so to populate the usedCoordinates.json
all the time. Given that Configuration cache state could not be cached
happens at the end of the build, it's weird that the json is not thereagrosner
03/07/2023, 7:29 PMmbonnin
03/07/2023, 7:29 PMagrosner
03/07/2023, 7:32 PMadd("apollo${service.capitalized()}DebugUsedCoordinatesConsumer", project)
add("apollo${service.capitalized()}ReleaseUsedCoordinatesConsumer", project)
not the main apolloUsedCoordinates
configurationsorg.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'apolloApi1UsedCoordinatesConsumer' not found.
apolloUsedCoordinates
configuration as expected, it still results in similiar configuration time errormbonnin
03/07/2023, 8:10 PM3.7.4
, right?agrosner
03/07/2023, 8:16 PMservice("api1Debug") {
srcDir(...) // src/debug, src/main
outputDirConnection {
connectToKotlinSourceSet("debug")
}
}
"api1Release" ^ same as above except release
"api2Debug"
"api2Release"
mbonnin
03/08/2023, 1:53 PM