Skip to content
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

feat!: upgrade to Apollo Kotlin 3.8.1 #71

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ All plugin configuration properties and their defaults:
<rootFolders>
<rootFolder>${project.basedir}/src/main/graphql/lahzouz/</rootFolder>
</rootFolders>
<customScalarsMapping></customScalarsMapping>
<scalarsMapping></scalarsMapping>
<operationIdGeneratorClass></operationIdGeneratorClass>
<schemaPackageName>com.lahzouz.apollo.graphql.client</schemaPackageName>
<packageName>com.lahzouz.apollo.graphql.client</packageName>
Expand All @@ -134,7 +134,9 @@ All plugin configuration properties and their defaults:
<generateResponseFields>false</generateResponseFields>
<generateSchema>false</generateSchema>
<generateTestBuilders>false</generateTestBuilders>
<moduleName>apollographql</moduleName>
<generateDataBuilders>false</generateDataBuilders>
<generateModelBuilders>false</generateModelBuilders>
<nullableFieldStyle>NONE</nullableFieldStyle>
<useSemanticNaming>true</useSemanticNaming>
<targetLanguage>JAVA</targetLanguage>
<sealedClassesForEnumsMatching></sealedClassesForEnumsMatching>
Expand Down Expand Up @@ -180,9 +182,9 @@ define mapping configuration then register your custom adapter:
----
<configuration>
...
<customScalarsMapping>
<scalarsMapping>
<Long>java.time.LocalDate</Long>
</customScalarsMapping>
</scalarsMapping>
...
</configuration>
----
Expand Down
10 changes: 5 additions & 5 deletions apollo-client-maven-plugin-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.aoudiamoncef</groupId>
<artifactId>apollo-client-maven-plugin-parent</artifactId>
<version>5.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -99,7 +99,7 @@
<plugin>
<groupId>com.github.aoudiamoncef</groupId>
<artifactId>apollo-client-maven-plugin</artifactId>
<version>5.0.0</version>
<version>6.0.0</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -141,9 +141,9 @@
<rootFolder>${project.basedir}/src/main/graphql/books/</rootFolder>
</rootFolders>
<generateKotlinModels>true</generateKotlinModels>
<customScalarsMapping>
<scalarsMapping>
<Long>java.lang.Long</Long>
</customScalarsMapping>
</scalarsMapping>
<operationIdGeneratorClass></operationIdGeneratorClass>
<schemaPackageName>com.lahzouz.apollo.graphql.client</schemaPackageName>
<packageName>com.lahzouz.apollo.graphql.client</packageName>
Expand All @@ -159,8 +159,8 @@
<generateTestBuilders>false</generateTestBuilders>
<generateOptionalOperationVariables>false
</generateOptionalOperationVariables>
<nullableFieldStyle>NONE</nullableFieldStyle>
<useSemanticNaming>true</useSemanticNaming>
<moduleName>apollographql</moduleName>
<targetLanguage>KOTLIN_1_5</targetLanguage>
<sealedClassesForEnumsMatching></sealedClassesForEnumsMatching>
<alwaysGenerateTypesMatching></alwaysGenerateTypesMatching>
Expand Down
2 changes: 1 addition & 1 deletion apollo-client-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.aoudiamoncef</groupId>
<artifactId>apollo-client-maven-plugin-parent</artifactId>
<version>5.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class GraphQLClientMojo : AbstractMojo() {

val metadata = compilerParams.metadataFiles.toList().map { ApolloMetadata.readFrom(it).compilerMetadata }

val scalarMapping = compilerParams.scalarsMapping.mapValues { ScalarInfo(it.value) }

ApolloCompiler.write(
Options(
schema = resolveSchema!!.toSchema(),
Expand All @@ -153,7 +155,7 @@ class GraphQLClientMojo : AbstractMojo() {
alwaysGenerateTypesMatching = compilerParams.alwaysGenerateTypesMatching,
operationOutputGenerator = operationOutputGenerator,
incomingCompilerMetadata = metadata,
customScalarsMapping = compilerParams.customScalarsMapping,
scalarMapping = scalarMapping,
codegenModels = compilerParams.codegenModels.label,
flattenModels = compilerParams.flattenModels,
useSemanticNaming = compilerParams.useSemanticNaming,
Expand All @@ -166,9 +168,11 @@ class GraphQLClientMojo : AbstractMojo() {
generateResponseFields = compilerParams.generateResponseFields,
generateQueryDocument = compilerParams.generateQueryDocument,
generateSchema = compilerParams.generateSchema,
moduleName = compilerParams.moduleName,
targetLanguage = compilerParams.targetLanguage,
generateTestBuilders = compilerParams.generateTestBuilders,
generateModelBuilders = compilerParams.generateModelBuilders,
generateDataBuilders = compilerParams.generateDataBuilders,
nullableFieldStyle = compilerParams.nullableFieldStyle,
sealedClassesForEnumsMatching = compilerParams.sealedClassesForEnumsMatching,
generateOptionalOperationVariables = compilerParams.generateOptionalOperationVariables
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CompilerParams {
*
* Default value: the empty map
*/
var customScalarsMapping: Map<String, String> = emptyMap()
var scalarsMapping: Map<String, String> = emptyMap()

/**
* By default, Apollo uses `Sha256` hashing algorithm to generate an ID for the query.
Expand Down Expand Up @@ -199,6 +199,43 @@ class CompilerParams {
*/
internal val generateTestBuilders: Boolean = false

/**
* Whether to generate the type safe Data builders. These are mainly used for tests but can also be used for other use
* cases too.
*
* Only valid when [generateKotlinModels] is true
*/
internal val generateDataBuilders: Boolean = false

/**
* Whether to generate builders for java models
*
* Default value: false
* Only valid when [generateKotlinModels] is false
*/
internal val generateModelBuilders: Boolean = false

/**
* The style to use for fields that are nullable in the Java generated code.
*
* Only valid when [targetLanguage] is [TargetLanguage.JAVA]
*
* Acceptable values:
* - `none`: Fields will be generated with the same type whether they are nullable or not
* - `apolloOptional`: Fields will be generated as Apollo's `com.apollographql.apollo3.api.Optional<Type>` if nullable, or `Type` if not.
* - `javaOptional`: Fields will be generated as Java's `java.util.Optional<Type>` if nullable, or `Type` if not.
* - `guavaOptional`: Fields will be generated as Guava's `com.google.common.base.Optional<Type>` if nullable, or `Type` if not.
* - `jetbrainsAnnotations`: Fields will be generated with Jetbrain's `org.jetbrains.annotations.Nullable` annotation if nullable, or
* `org.jetbrains.annotations.NotNull` if not.
* - `androidAnnotations`: Fields will be generated with Android's `androidx.annotation.Nullable` annotation if nullable, or
* `androidx.annotation.NonNull` if not.
* - `jsr305Annotations`: Fields will be generated with JSR 305's `javax.annotation.Nullable` annotation if nullable, or
* `javax.annotation.Nonnull` if not.
*
* Default: `none`
*/
internal val nullableFieldStyle: JavaNullable = JavaNullable.NONE

// TODO to be handled
/**
* What codegen to use. One of "OPERATION", "RESPONSE" or "COMPATIBILITY"
Expand All @@ -215,11 +252,6 @@ class CompilerParams {
*/
internal val flattenModels: Boolean = true

/**
* The moduleName for this metadata. Used for debugging purposes
*/
internal val moduleName: String = "apollographql"

internal val logger: ApolloCompiler.Logger = ApolloCompiler.NoOpLogger

/**
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.aoudiamoncef</groupId>
<artifactId>apollo-client-maven-plugin-parent</artifactId>
<version>5.0.0</version>
<version>6.0.0</version>
<packaging>pom</packaging>

<name>apollo-client-maven-plugin-parent</name>
Expand All @@ -30,7 +30,7 @@

<annotations.version>23.0.0</annotations.version>
<ant.version>1.10.12</ant.version>
<apollo.version>3.0.0</apollo.version>
<apollo.version>3.8.1</apollo.version>
<assertj-core.version>3.22.0</assertj-core.version>
<graphql-java-servlet.version>6.1.3</graphql-java-servlet.version>
<graphql-java-tools.version>5.2.4</graphql-java-tools.version>
Expand Down