Skip to content

Commit 2ed7266

Browse files
committed
Migrate to jackson 3
1 parent a18ed9b commit 2ed7266

84 files changed

Lines changed: 281 additions & 282 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ plugins {
66
id "java-library"
77
id "signing"
88
id "maven-publish"
9-
id "org.sonarqube" version "4.0.0.2929"
109
}
1110

1211
def graphqlCodegenVersion = '5.10.1-SNAPSHOT' // This variable used in the automatic release process
@@ -19,9 +18,10 @@ repositories {
1918
}
2019

2120
dependencies {
21+
implementation platform("tools.jackson:jackson-bom:3.0.3")
2222
compileOnly "org.freemarker:freemarker:2.3.32"
2323
compileOnly "com.graphql-java:graphql-java:20.2"
24-
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.15.3"
24+
compileOnly "tools.jackson.core:jackson-databind"
2525
compileOnly "com.typesafe:config:1.4.3"
2626

2727
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.2"

docs/codegen-options.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
| `generateSealedInterfaces` | Boolean | False | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin and Scala. |
6868
| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
6969
| `fieldsWithDataFetcherResult` | Set(String) | Empty | Types that must have DataFetchResult should be defined here in format: `TypeName`, or `TypeName.fieldName` or `@directive`. E.g.: `Item`, `Item.items` or `@dataFetcherResult`. |
70-
| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `com.fasterxml.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
70+
| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `tools.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
7171
| `supportUnknownFields` | Boolean | False | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map<String,Object>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields. |
7272
| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization |
7373
| `skip` | Boolean | False | If true, then code generation will not happen |
@@ -161,9 +161,9 @@ Can be used to supply custom annotations (serializers) for scalars.
161161
Supports following formats:
162162

163163
* Map of (GraphQLObjectName.fieldName) to (JavaAnnotation).
164-
E.g.: `Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)`
164+
E.g.: `Event.dateTime = @tools.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)`
165165
* Map of (GraphQLType) to (JavaAnnotation).
166-
E.g.: `EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)`
166+
E.g.: `EpochMillis = @tools.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)`
167167

168168
### Option `directiveAnnotationsMapping`
169169

@@ -239,7 +239,7 @@ customTypesMapping={
239239
Object="org.json.JSONObject"
240240
}
241241
customAnnotationsMapping={
242-
"QuestionNode.metaData"=["com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.github.dreamylost.JsonObjectDeserializer::class)"]
243-
"QuestionNode.envInfo"=["com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.github.dreamylost.JsonObjectDeserializer::class)"]
242+
"QuestionNode.metaData"=["tools.jackson.databind.annotation.JsonDeserialize(using = com.github.dreamylost.JsonObjectDeserializer::class)"]
243+
"QuestionNode.envInfo"=["tools.jackson.databind.annotation.JsonDeserialize(using = com.github.dreamylost.JsonObjectDeserializer::class)"]
244244
}
245245
```

docs/migration-to-3.0.0.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ by providing an array of annotations in the following format:
7272
<!--OLD APPROACH-->
7373
<customAnnotationsMapping>
7474
<Character>
75-
com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
76-
com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)
75+
tools.jackson.annotation.JsonTypeInfo(use = tools.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
76+
tools.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)
7777
</Character>
7878
</customAnnotationsMapping>
7979
<directiveAnnotationsMapping>
@@ -84,8 +84,8 @@ by providing an array of annotations in the following format:
8484
<!--NEW APPROACH-->
8585
<customAnnotationsMapping>
8686
<Character>
87-
<annotation1>com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")</annotation1>
88-
<annotation2>com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)</annotation2>
87+
<annotation1>tools.jackson.annotation.JsonTypeInfo(use = tools.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")</annotation1>
88+
<annotation2>tools.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)</annotation2>
8989
</Character>
9090
</customAnnotationsMapping>
9191
<directiveAnnotationsMapping>
@@ -102,9 +102,9 @@ by providing an array of annotations in the following format:
102102
```groovy
103103
// OLD APPROACH
104104
customAnnotationsMapping = [
105-
"Character": "com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")"
105+
"Character": "tools.jackson.annotation.JsonTypeInfo(use = tools.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")"
106106
+ System.lineSeparator()
107-
+ "com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
107+
+ "tools.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
108108
]
109109
directiveAnnotationsMapping = [
110110
"auth": "org.springframework.security.access.annotation.Secured({{roles}})"
@@ -114,8 +114,8 @@ directiveAnnotationsMapping = [
114114
// NEW APPROACH
115115
customAnnotationsMapping = [
116116
"Character": [
117-
"com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")",
118-
"com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
117+
"tools.jackson.annotation.JsonTypeInfo(use = tools.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")",
118+
"tools.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
119119
]
120120
]
121121
directiveAnnotationsMapping = [
@@ -134,9 +134,9 @@ customAnnotationsMapping := {
134134
//property is __typename and you must use with __typename while invoke, like new CharacterResponseProjection().id().name().typename()
135135
//and in @JsonSubTypes.Type, name is __typename's value
136136
mapping.put("Character",
137-
s"""@com.fasterxml.jackson.annotation.JsonTypeInfo(use=com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include=com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = "__typename")${System.lineSeparator()}@com.fasterxml.jackson.annotation.JsonSubTypes(value = {
138-
| @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = HumanDO.class, name = "Human"),
139-
| @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = DroidDO.class, name = "Droid")})
137+
s"""@tools.jackson.annotation.JsonTypeInfo(use=tools.jackson.annotation.JsonTypeInfo.Id.NAME, include=tools.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = "__typename")${System.lineSeparator()}@tools.jackson.annotation.JsonSubTypes(value = {
138+
| @tools.jackson.annotation.JsonSubTypes.Type(value = HumanDO.class, name = "Human"),
139+
| @tools.jackson.annotation.JsonSubTypes.Type(value = DroidDO.class, name = "Droid")})
140140
|""".stripMargin)
141141
mapping
142142
}
@@ -146,10 +146,10 @@ customAnnotationsMapping := {
146146
customAnnotationsMapping := {
147147
val mapping = new util.HashMap[String, util.List[String]]
148148
val annotations = new util.ArrayList[String]()
149-
annotations.add("@com.fasterxml.jackson.annotation.JsonTypeInfo(use=com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include=com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")")
150-
annotations.add("""@com.fasterxml.jackson.annotation.JsonSubTypes(value = {
151-
| @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = HumanDO.class, name = "Human"),
152-
| @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = DroidDO.class, name = "Droid")})""".stripMargin)
149+
annotations.add("@tools.jackson.annotation.JsonTypeInfo(use=tools.jackson.annotation.JsonTypeInfo.Id.NAME, include=tools.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")")
150+
annotations.add("""@tools.jackson.annotation.JsonSubTypes(value = {
151+
| @tools.jackson.annotation.JsonSubTypes.Type(value = HumanDO.class, name = "Human"),
152+
| @tools.jackson.annotation.JsonSubTypes.Type(value = DroidDO.class, name = "Droid")})""".stripMargin)
153153
//must add this annotation
154154
//property is __typename and you must use with __typename while invoke, like new CharacterResponseProjection().id().name().typename()
155155
//and in @JsonSubTypes.Type, name is __typename's value

plugins/gradle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ graphqlCodegen {
5858
Price.amount: "java.math.BigDecimal"
5959
]
6060
customAnnotationsMapping = [
61-
DateTime: ["@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class)"]
61+
DateTime: ["@tools.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class)"]
6262
]
6363
modelNameSuffix = "TO"
6464
}
@@ -83,7 +83,7 @@ tasks.named<GraphQLCodegenGradleTask>("graphqlCodegen") {
8383
outputDir = File("$buildDir/generated")
8484
packageName = "com.example.graphql.model"
8585
customTypesMapping = mutableMapOf(Pair("EpochMillis", "java.time.LocalDateTime"))
86-
customAnnotationsMapping = mutableMapOf(Pair("EpochMillis", listOf("@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class)")))
86+
customAnnotationsMapping = mutableMapOf(Pair("EpochMillis", listOf("@tools.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class)")))
8787
}
8888

8989
// Automatically generate GraphQL code on project build:

plugins/gradle/example-client-kotlin/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ dependencies {
3232

3333
implementation "javax.validation:validation-api:2.0.1.Final"
3434
implementation "com.squareup.okhttp3:okhttp:4.11.0"
35-
implementation "com.fasterxml.jackson.core:jackson-core:2.15.3"
36-
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.3"
37-
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2"
38-
implementation "com.fasterxml.jackson.core:jackson-annotations:2.15.3"
35+
implementation "tools.jackson.core:jackson-core:2.15.3"
36+
implementation "tools.jackson.core:jackson-databind:2.15.3"
37+
implementation "tools.jackson.module:jackson-module-kotlin:2.15.2"
38+
implementation "tools.jackson.core:jackson-annotations:2.15.3"
3939
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
4040

4141
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.2"
@@ -60,10 +60,10 @@ task graphqlCodegenKotlinService(type: GraphQLCodegenGradleTask) {
6060
generateModelOpenClasses = true
6161
generateSealedInterfaces = true
6262
customAnnotationsMapping = [
63-
"Character": ["@com.fasterxml.jackson.annotation.JsonTypeInfo(use=com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include=com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")",
64-
"@com.fasterxml.jackson.annotation.JsonSubTypes(value = arrayOf(" + System.lineSeparator() +
65-
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = HumanTO::class, name = \"Human\"), " + System.lineSeparator() +
66-
" com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = DroidTO::class, name = \"Droid\")))"],
63+
"Character": ["@tools.jackson.annotation.JsonTypeInfo(use=tools.jackson.annotation.JsonTypeInfo.Id.NAME, include=tools.jackson.annotation.JsonTypeInfo.As.PROPERTY,property = \"__typename\")",
64+
"@tools.jackson.annotation.JsonSubTypes(value = arrayOf(" + System.lineSeparator() +
65+
" tools.jackson.annotation.JsonSubTypes.Type(value = HumanTO::class, name = \"Human\"), " + System.lineSeparator() +
66+
" tools.jackson.annotation.JsonSubTypes.Type(value = DroidTO::class, name = \"Droid\")))"],
6767
]
6868
modelNameSuffix = "TO"
6969
supportUnknownFields = true

plugins/gradle/example-client-kotlin/src/main/kotlin/io/github/dreamylost/QueryResolverImpl.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.github.dreamylost
22

3-
import com.fasterxml.jackson.annotation.JsonInclude
4-
import com.fasterxml.jackson.databind.DeserializationFeature
5-
import com.fasterxml.jackson.module.kotlin.jsonMapper
6-
import com.fasterxml.jackson.module.kotlin.kotlinModule
7-
import com.fasterxml.jackson.module.kotlin.readValue
3+
import tools.jackson.annotation.JsonInclude
4+
import tools.jackson.databind.DeserializationFeature
5+
import tools.jackson.module.kotlin.jsonMapper
6+
import tools.jackson.module.kotlin.kotlinModule
7+
import tools.jackson.module.kotlin.readValue
88
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequest
99
import io.github.dreamylost.api.QueryResolver
1010
import io.github.dreamylost.model.*

plugins/gradle/example-client/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ task graphqlCodegenStarwarsService(type: GraphQLCodegenGradleTask) {
8585
packageName = "io.github.kobylynskyi.starwars.graphql"
8686
customAnnotationsMapping = [
8787
"Character": [
88-
"@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")",
89-
"@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
88+
"@tools.jackson.annotation.JsonTypeInfo(use = tools.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")",
89+
"@tools.jackson.databind.annotation.JsonTypeIdResolver(io.github.kobylynskyi.order.external.starwars.CharacterTypeResolver.class)"
9090
]
9191
]
9292
generateClient = true

plugins/gradle/example-client/src/main/java/io/github/kobylynskyi/order/external/product/ProductServiceGraphQLClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.kobylynskyi.order.external.product;
22

3-
import com.fasterxml.jackson.databind.ObjectMapper;
3+
import tools.jackson.databind.json.JsonMapper;
44
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequest;
55
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequests;
66
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponse;

plugins/gradle/example-client/src/main/java/io/github/kobylynskyi/order/external/starwars/CharacterTypeResolver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.github.kobylynskyi.order.external.starwars;
22

3-
import com.fasterxml.jackson.annotation.JsonTypeInfo;
4-
import com.fasterxml.jackson.databind.DatabindContext;
5-
import com.fasterxml.jackson.databind.JavaType;
6-
import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
3+
import tools.jackson.annotation.JsonTypeInfo;
4+
import tools.jackson.databind.DatabindContext;
5+
import tools.jackson.databind.JavaType;
6+
import tools.jackson.databind.jsontype.impl.TypeIdResolverBase;
77
import io.github.kobylynskyi.starwars.graphql.Droid;
88
import io.github.kobylynskyi.starwars.graphql.Human;
99

plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828

2929
implementation "org.freemarker:freemarker:2.3.32"
3030
implementation "com.graphql-java:graphql-java:20.2"
31-
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.3"
31+
implementation "tools.jackson.core:jackson-databind"
3232
implementation "com.typesafe:config:1.4.3"
3333

3434
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'

0 commit comments

Comments
 (0)