-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the compiler accept Json configuration files #5516
Conversation
✅ Deploy Preview for apollo-android-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
86ced24
to
d199709
Compare
@@ -144,7 +144,6 @@ kotlin-node = "org.jetbrains.kotlin-wrappers:kotlin-node:18.16.12-pre.634" | |||
kotlinx-serialization-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin-plugin" } | |||
kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinx-serialization-runtime" } | |||
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-runtime" } | |||
kotlinx-serialization-json-okio = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-okio", version.ref = "kotlinx-serialization-runtime" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not stable so removing from the apollo-compiler API since users may start using the apollo-compiler API directly with this PR (some might have done so already but apollo-compiler was mostly used by the Gradle plugin so far)
public static final fun toCodegenMetadata (Ljava/io/File;)Lcom/apollographql/apollo3/compiler/CodegenMetadata; | ||
public static final fun writeTo (Lcom/apollographql/apollo3/compiler/CodegenMetadata;Ljava/io/File;)V |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking changes everywhere in this file. I declare them OK cause the apollo-compiler API was not really meant to be accessed outside the Gradle Plugin.
val duplicates = irOperations.flatMapIndexed { index, irOperations1 -> | ||
irOperations1.fragmentDefinitions.map { it.name to irOperationsFiles.get(index).path } | ||
}.groupBy { it.first }.mapValues { it.value.map { it.second } } | ||
.entries | ||
.filter { it.value.size > 1 } | ||
.flatMap { entry -> | ||
entry.value.map { | ||
"- ${entry.key}: $it" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this was not really needed as the check is already done here.
This means it's ok to have clashing fragments in sibling modules as long as they have different package names.
val packageNameGenerator = packageNameGenerator ?: packageNameGenerator( | ||
codegenSchemaOptions.packageName, | ||
codegenSchemaOptions.packageNamesFromFilePaths, | ||
packageNameRoots | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the prep work for moving packageNameGenerator
to a ServiceLoader
. We would still support packageName
and packageNamesFromFilePaths
as declarative options present in the JSON files that can be overriden by a compiler plugin if needed.
This should now be ready for review. Initial description updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚙️
The compiler can be used from different contexts:
In order to make it easier to work in these different contexts, make the compiler accept JSON configuration files.
Instead of having conventions and default behaviours in the Gradle Plugin, they are now in the Compiler.