Skip to content

Commit

Permalink
Add customTypesMapping for backward compatibility (#3452)
Browse files Browse the repository at this point in the history
* Add customTypesMapping for backward compatibility

See #3410

* make apiCheck happy 🎉
  • Loading branch information
martinbonnin authored Oct 27, 2021
1 parent f1fb6f1 commit b5be933
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions apollo-gradle-plugin/api/apollo-gradle-plugin.api
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract interface class com/apollographql/apollo3/gradle/api/Service {
public abstract fun getAlwaysGenerateTypesMatching ()Lorg/gradle/api/provider/SetProperty;
public abstract fun getCodegenModels ()Lorg/gradle/api/provider/Property;
public abstract fun getCustomScalarsMapping ()Lorg/gradle/api/provider/MapProperty;
public abstract fun getCustomTypeMapping ()Lorg/gradle/api/provider/MapProperty;
public abstract fun getDebugDir ()Lorg/gradle/api/file/DirectoryProperty;
public abstract fun getExcludes ()Lorg/gradle/api/provider/ListProperty;
public abstract fun getFailOnWarnings ()Lorg/gradle/api/provider/Property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ interface Service {
*/
val customScalarsMapping: MapProperty<String, String>

@Deprecated("customTypeMapping is a helper property to help migrating to 3.x " +
"and will be removed in a future version", ReplaceWith("customScalarsMapping"))
val customTypeMapping: MapProperty<String, String>

/**
* By default, Apollo uses `Sha256` hashing algorithm to generate an ID for the query.
* To provide a custom ID generation logic, pass an `instance` that implements the [OperationIdGenerator]. How the ID is generated is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ abstract class DefaultApolloExtension(
&& defaultService.schemaFiles.isEmpty
&& defaultService.alwaysGenerateTypesMatching.isPresent.not()
&& defaultService.customScalarsMapping.isPresent.not()
&& defaultService.customTypeMapping.isPresent.not()
&& defaultService.excludes.isPresent.not()
&& defaultService.includes.isPresent.not()
&& defaultService.failOnWarnings.isPresent.not()
Expand Down Expand Up @@ -405,7 +406,7 @@ abstract class DefaultApolloExtension(
task.generateKotlinModels.set(service.generateKotlinModels)
task.warnOnDeprecatedUsages.set(service.warnOnDeprecatedUsages)
task.failOnWarnings.set(service.failOnWarnings)
task.customScalarsMapping.set(service.customScalarsMapping)
task.customScalarsMapping.set(service.customScalarsMapping.orElse(service.customTypeMapping))
task.outputDir.apply {
set(service.outputDir.orElse(BuildDirLayout.outputDir(project, service)).get())
disallowChanges()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ abstract class DefaultService @Inject constructor(val project: Project, override
// This allows users to call customScalarsMapping.put("Date", "java.util.Date")
// see https://github.com/gradle/gradle/issues/7485
customScalarsMapping.convention(null as Map<String, String>?)
customTypeMapping.convention(null as Map<String, String>?)
includes.convention(null as List<String>?)
excludes.convention(null as List<String>?)
alwaysGenerateTypesMatching.convention(null as Set<String>?)
sealedClassesForEnumsMatching.convention(null as List<String>?)
} else {
customScalarsMapping.set(null as Map<String, String>?)
customTypeMapping.set(null as Map<String, String>?)
includes.set(null as List<String>?)
excludes.set(null as List<String>?)
alwaysGenerateTypesMatching.set(null as Set<String>?)
Expand Down

0 comments on commit b5be933

Please sign in to comment.