Skip to content

BREAKING CHANGE: Upgrade to Jackson 3#2162

Merged
samuelAndalon merged 10 commits intomasterfrom
jackson-upgrade
Apr 6, 2026
Merged

BREAKING CHANGE: Upgrade to Jackson 3#2162
samuelAndalon merged 10 commits intomasterfrom
jackson-upgrade

Conversation

@JordanJLopez
Copy link
Copy Markdown
Collaborator

@JordanJLopez JordanJLopez commented Apr 3, 2026

Helpful Context:

In my previous Spring Boot breaking change PR, I assumed that since graphql-java used Jackson 2 that we'd be pinned to that as well. However, on further review, they're only using it as a test dependency.

So, this PR takes on the migration to Jackson 3.

Big highlights:

  • Use the Spring-preferred spring-boot-jackson instead of spring-boot-jackson2
  • Bring in ktor support for jackson 3 by moving from ktor-serialization-jackson to ktor-serialization-jackson3
    • Added in 3.4.0 with https://github.com/ktorio/ktor/pull/5301
  • The package for most Jackson classes changed from com.fasterxml.jackson.* to tools.jackson.*
    • With the exception of *.annotation.* classes, those remain under the old package path
  • ObjectMappers are now immutable, the new pattern is provide builder modifications

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the project’s JSON stack to Jackson 3 (and aligns Spring/Ktor integrations accordingly), updating runtime code, tests, benchmarks, and documentation to the new Jackson APIs and coordinates.

Changes:

  • Bump Jackson to v3 and switch dependency coordinates/imports from com.fasterxml.jackson.* to tools.jackson.* across modules.
  • Update server/client JSON (de)serialization and request parsing code paths for Jackson 3 APIs and related framework integrations (Spring Boot 4, Ktor jackson3).
  • Refresh documentation and tests to reflect the new Jackson 3 configuration model (properties/customizers) and updated request/response expectations.

Reviewed changes

Copilot reviewed 96 out of 96 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
website/docs/server/spring-server/spring-properties.md Adds Jackson properties guidance for Spring Boot-based configuration.
website/docs/server/spring-server/spring-overview.mdx Documents Spring Boot 4 + Jackson 3 configuration recommendations.
website/docs/server/spring-server/spring-beans.md Clarifies mapper ownership (Spring Boot auto-config) for the Spring server module.
website/docs/server/ktor-server/ktor-configuration.md Updates Ktor samples to use JsonMapper builder style and jackson3-compatible APIs.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/subscriptions/SubscriptionWebSocketHandlerTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/subscriptions/ApolloSubscriptionWebSocketHandlerIT.kt Updates Jackson imports for tests.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/subscriptions/ApolloSubscriptionProtocolHandlerTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/SubscriptionConfigurationTest.kt Updates Jackson imports and comments for Boot/Jackson 3.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/SchemaConfigurationTest.kt Updates Jackson imports and ordering/cleanup.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/routes/SubscriptionRoutesConfigurationIT.kt Updates Jackson imports and removes explicit Kotlin module registration.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/routes/RouteConfigurationIT.kt Updates Jackson imports for tests.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/routes/ApolloSubscriptionRoutesConfigurationIT.kt Updates Jackson imports and removes explicit Kotlin module registration.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/FederationConfigurationTest.kt Updates Jackson imports and comments for Boot/Jackson 3.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/execution/SpringGraphQLRequestParserTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/execution/DataFetcherIT.kt Adjusts/removes Jackson customization snippet in test config (currently commented).
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/subscriptions/SubscriptionWebSocketHandler.kt Switches ObjectMapper import to tools.jackson.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/subscriptions/ApolloSubscriptionWebSocketHandler.kt Switches ObjectMapper import to tools.jackson.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/subscriptions/ApolloSubscriptionProtocolHandler.kt Switches ObjectMapper + kotlin-module helpers to tools.jackson.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/SubscriptionGraphQLWsAutoConfiguration.kt Switches ObjectMapper import to tools.jackson and reorders imports.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/SubscriptionApolloWsAutoConfiguration.kt Switches ObjectMapper import to tools.jackson.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/GraphQLServerCodecConfiguration.kt Updates Fastjson2 Spring 6 codec wiring and removes ObjectMapper injection.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/GraphQLSchemaConfiguration.kt Switches ObjectMapper import to tools.jackson and minor import reordering.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/GraphQLExecutionConfiguration.kt Removes Jackson2 auto-config import and tweaks dataloader factory wiring.
servers/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/server/spring/execution/SpringGraphQLRequestParser.kt Switches Jackson types to tools.jackson and updates TypeFactory usage.
servers/graphql-kotlin-spring-server/README.md Adds Jackson 3 configuration guidance for Spring Boot 4.
servers/graphql-kotlin-spring-server/build.gradle.kts Switches from spring-boot-jackson2 to spring-boot-jackson.
servers/graphql-kotlin-server/src/test/kotlin/com/expediagroup/graphql/server/types/GraphQLServerResponseTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-server/src/test/kotlin/com/expediagroup/graphql/server/types/GraphQLServerRequestTest.kt Updates Jackson imports for tests/exceptions.
servers/graphql-kotlin-server/src/test/kotlin/com/expediagroup/graphql/server/types/GraphQLErrorTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-server/src/test/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServerTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/types/GraphQLSubscriptionMessage.kt Migrates custom deserializer and annotations to Jackson 3 APIs.
servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/types/GraphQLServerResponse.kt Migrates custom deserializer and annotations to Jackson 3 APIs.
servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/types/GraphQLServerRequest.kt Migrates custom deserializer and annotations to Jackson 3 APIs.
servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServer.kt Switches ObjectMapper/imports and updates opt-in annotations.
servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerResponseSerializationBenchmark.kt Updates Jackson imports for benchmarks.
servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerResponseBatchSerializationBenchmark.kt Updates Jackson imports for benchmarks.
servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerRequestDeserializationBenchmark.kt Updates Jackson imports for benchmarks.
servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerRequestBatchDeserializationBenchmark.kt Updates Jackson imports for benchmarks.
servers/graphql-kotlin-ktor-server/src/test/kotlin/com/expediagroup/graphql/server/ktor/KtorGraphQLRequestParserTest.kt Updates Jackson imports for tests.
servers/graphql-kotlin-ktor-server/src/test/kotlin/com/expediagroup/graphql/server/ktor/GraphQLPluginTest.kt Switches Ktor serialization import to jackson3.
servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/subscriptions/KtorGraphQLWebSocketServer.kt Switches ObjectMapper import to tools.jackson.
servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/KtorGraphQLRequestParser.kt Switches Jackson types to tools.jackson and updates TypeFactory usage.
servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLRoutes.kt Switches Ktor serialization import to jackson3 and updates API signatures to JsonMapper.Builder.
servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLConfiguration.kt Updates default request parser to use JsonMapper builder and updates config type.
servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQL.kt Uses JsonMapper builder for websocket server ObjectMapper creation.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/union/GenerateGraalVmUnionMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/types/GenerateGraalVmTypeMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/primitive/GenerateGraalVmPrimitiveMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/list/GenerateGraalVmListMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/intf/GenerateGraalVmInterfaceMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/inner/GenerateGraalVmInnerClassMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/id/GenerateGraalVmIdMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/enums/GenerateGraalVmEnumMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/coroutine/GenerateGraalVmCoroutineMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/test/kotlin/com/expediagroup/graphql/plugin/graalvm/boxed/GenerateGraalVmBoxedMetadataTest.kt Updates mapper creation to jacksonMapperBuilder and Jackson 3 inclusion API.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/main/kotlin/com/expediagroup/graphql/plugin/graalvm/GenerateGraalVmMetadata.kt Migrates ObjectMapper creation/config to Jackson 3 builder APIs.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/main/kotlin/com/expediagroup/graphql/plugin/graalvm/DefaultMetadataLoader.kt Updates Jackson imports for loader.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/integrationTest/kotlin/com/expediagroup/graphql/plugin/graalvm/federated/GenerateGraalVmEntityMetadataTest.kt Updates mapper creation to Jackson 3 builder APIs.
plugins/server/graphql-kotlin-graalvm-metadata-generator/src/integrationTest/kotlin/com/expediagroup/graphql/plugin/graalvm/custom/GenerateGraalVmCustomScalarMetadataTest.kt Updates mapper creation to Jackson 3 builder APIs.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalars/scalars/UUIDToAnyConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalars/scalars/ULocaleToAnyConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalars/scalars/AnyToUUIDConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalars/scalars/AnyToULocaleConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalars/customscalarquery/ScalarWrapper.kt Updates Jackson annotation imports to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/scalars/UUIDToAnyConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/scalars/ULocaleToAnyConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/scalars/OptionalScalarInputSerializer.kt Migrates serializer to Jackson 3 APIs (ValueSerializer/SerializationContext).
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/scalars/AnyToUUIDConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/scalars/AnyToULocaleConverter.kt Updates StdConverter import to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/inputs/ScalarWrapperInput.kt Updates Jackson annotation imports to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/test/data/jackson/custom_scalar_input/CustomScalarInputQuery.kt Updates Jackson annotation imports to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/introspectSchema.kt Switches Ktor serialization import to jackson3.
plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/generator/types/generatePropertySpecs.kt Switches JsonSerialize/JsonDeserialize imports to tools.jackson.
plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/generator/types/generateJacksonOptionalInputScalarSerializer.kt Migrates generated OptionalInput serializer template to Jackson 3 APIs.
plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/generator/types/generateGraphQLCustomScalarConverters.kt Switches StdConverter import to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/polymorphic-types-kotlinx/src/main/kotlin/com/expediagroup/polymorphic/KtorGraphQLServer.kt Updates ObjectMapper import to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/polymorphic-types-kotlinx/src/main/kotlin/com/expediagroup/polymorphic/Application.kt Updates Jackson imports to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/ktor-kotlinx/src/main/kotlin/com/expediagroup/ktor/kotlinx/KtorGraphQLServer.kt Updates ObjectMapper import to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/ktor-kotlinx/src/main/kotlin/com/expediagroup/ktor/kotlinx/Application.kt Updates Jackson imports to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/ktor-jackson/src/main/kotlin/com/expediagroup/ktor/jackson/KtorGraphQLServer.kt Updates ObjectMapper import to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/ktor-jackson/src/main/kotlin/com/expediagroup/ktor/jackson/Application.kt Updates Jackson imports to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/main/kotlin/com/expediagroup/scalars/KtorGraphQLServer.kt Updates ObjectMapper import to tools.jackson.
integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/main/kotlin/com/expediagroup/scalars/Application.kt Updates Jackson imports to tools.jackson.
gradle/libs.versions.toml Bumps Jackson to 3.1.1, updates Jackson/Ktor/Spring Boot coordinates, bumps fastjson2.
examples/client/maven-client/src/main/kotlin/com/expediagroup/graphql/examples/client/maven/ProductEntityRepresentation.kt Ensures __typename serializes via JsonProperty getter annotation.
clients/graphql-kotlin-spring-client/src/test/kotlin/com/expediagroup/graphql/client/spring/GraphQLWebClientTest.kt Updates Jackson imports and improves WireMock query param matching for APQ.
clients/graphql-kotlin-ktor-client/src/test/kotlin/com/expediagroup/graphql/client/ktor/GraphQLKtorClientTest.kt Updates Jackson imports and improves WireMock query param matching for APQ.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/serializers/OptionalInputSerializerTest.kt Updates mapper setup to Jackson 3 builder APIs.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/GraphQLClientJacksonSerializerTest.kt Updates mapper creation and compares JSON structurally instead of raw string equality.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/data/scalars/UUIDConverters.kt Updates StdConverter import to tools.jackson.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/data/scalars/AnyToAnyConverter.kt Updates StdConverter import and adds __typename JsonProperty on getter.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/data/ScalarQuery.kt Updates JsonSerialize/JsonDeserialize imports and use-site targets.
clients/graphql-kotlin-client-jackson/src/test/kotlin/com/expediagroup/graphql/client/jackson/data/EntitiesQuery.kt Updates JsonSerialize/JsonDeserialize imports and use-site targets.
clients/graphql-kotlin-client-jackson/src/main/kotlin/com/expediagroup/graphql/client/jackson/types/OptionalInput.kt Switches JsonSerialize import to tools.jackson.
clients/graphql-kotlin-client-jackson/src/main/kotlin/com/expediagroup/graphql/client/jackson/serializers/OptionalInputSerializer.kt Migrates serializer to Jackson 3 ValueSerializer/SerializationContext.
clients/graphql-kotlin-client-jackson/src/main/kotlin/com/expediagroup/graphql/client/jackson/GraphQLClientJacksonSerializer.kt Migrates ObjectMapper configuration to Jackson 3 builder/rebuild APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JordanJLopez and others added 7 commits April 3, 2026 10:18
…/com/expediagroup/graphql/plugin/client/generator/types/generateJacksonOptionalInputScalarSerializer.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ackson/custom_scalar_input/scalars/OptionalScalarInputSerializer.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 101 out of 101 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

class SubscriptionConfiguration {

// in regular apps object mapper will be created by JacksonAutoConfiguration
// in regular apps object mapper will be created by spring-boot-jackson
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading: spring-boot-jackson is a dependency/module, but the ObjectMapper bean is created by Spring Boot auto-configuration (e.g., Jackson auto-config) when the relevant conditions are met. Consider rewording to reference Spring Boot Jackson auto-configuration rather than the module name.

Copilot uses AI. Check for mistakes.
class CustomFederatedConfiguration {

// in regular apps object mapper will be created by JacksonAutoConfiguration
// in regular apps object mapper will be created by spring-boot-jackson
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading: the mapper bean comes from Spring Boot Jackson auto-configuration, not from the spring-boot-jackson module by itself. Consider rewording.

Copilot uses AI. Check for mistakes.
Comment thread website/docs/server/spring-server/spring-overview.mdx Outdated
@JordanJLopez
Copy link
Copy Markdown
Collaborator Author

@copilot apply changes based on the comments in this thread

…d fix misleading comments

Agent-Logs-Url: https://github.com/ExpediaGroup/graphql-kotlin/sessions/d4b80a93-e497-46df-b6e4-5196744d13ba

Co-authored-by: JordanJLopez <8593393+JordanJLopez@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied all changes from that review thread in commit d0d0882:

  • Changed @param:JsonSerialize/@param:JsonDeserialize to @get: in ScalarQuery.kt and EntitiesQuery.kt so serialization annotations are resolved from the getter/field rather than the constructor parameter.
  • Updated misleading comments in SubscriptionConfigurationTest.kt, SchemaConfigurationTest.kt, and FederationConfigurationTest.kt to reference "Spring Boot Jackson auto-configuration" instead of the spring-boot-jackson module name.

import tools.jackson.databind.SerializationContext
import tools.jackson.databind.ValueSerializer

class OptionalInputSerializer : JsonSerializer<OptionalInput<*>>() {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class OptionalInputSerializer : JsonSerializer<OptionalInput<*>>() {
class OptionalInputSerializer : ValueSerializer<OptionalInput<*>>() {

override fun isEmpty(provider: SerializerProvider, value: OptionalInput<*>?): Boolean {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed, and the default name of the parameter is ctxt so I changed it to align: https://github.com/FasterXML/jackson-databind/blob/3.x/src/main/java/tools/jackson/databind/ValueSerializer.java#L223

Comment on lines +66 to +77
companion object {
private fun configureMapper(mapper: JsonMapper): JsonMapper = mapper.rebuild()
.enable(EnumFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
.changeDefaultPropertyInclusion { it.withValueInclusion(JsonInclude.Include.NON_NULL) }
.withConfigOverride(OptionalInput::class.java) { cfg ->
cfg.setInclude(
JsonInclude.Value.empty()
.withValueInclusion(JsonInclude.Include.CUSTOM)
.withValueFilter(UndefinedFilter::class.java)
)
}
.build()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ObjectMapper objects are now immutable, so we need to rebuild it to apply the settings that we need.


// representation would not be part of the generated sources
data class ProductEntityRepresentation(val id: String) {
@get:JsonProperty("__typename")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of the upgrade, this explicit annotation is now required. Previously it would be fine for it to be implicit.

Comment on lines +27 to +29
private val mapper = jacksonMapperBuilder()
.changeDefaultPropertyInclusion { incl -> incl.withValueInclusion(JsonInclude.Include.NON_EMPTY) }
.build()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates the new builder pattern

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonDeserialize(using = JsonDeserializer.None::class)
@JsonDeserialize(using = ValueDeserializer.None::class)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): GraphQLServerRequest {
val codec = parser.codec
val jsonNode = codec.readTree<JsonNode>(parser)
val objectReadContext = parser.objectReadContext()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +73 to +76
objectReadContext.treeAsTokens(jsonNode).use { treeParser ->
treeParser.nextToken() // ensure positioned at first token
objectReadContext.readValue(treeParser, GraphQLBatchRequest::class.java)
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old treeToValue: https://github.com/FasterXML/jackson-core/blob/2.19/src/main/java/com/fasterxml/jackson/core/ObjectCodec.java#L241-L256

New treeAsToken: https://github.com/FasterXML/jackson-core/blob/3.x/src/main/java/tools/jackson/core/ObjectReadContext.java#L79-L92

There is not a 1:1 convenience method equivalent in the newer version for treeToValue.

Instead, we use the treeAsTokens to provide a parser and then use that parser to read the value.

Comment on lines +91 to +92
fun jsonMapperBuilderCustomizer() = JsonMapperBuilderCustomizer { builder ->
builder.configure(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS, false)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JavaTimeModule has been folded in and is included by default https://github.com/FasterXML/jackson-modules-java8?tab=readme-ov-file#jackson-3x

To keep the spirit of the test, I subbed in a different configuration.

.build()
}

val objectMapper = jacksonObjectMapper().registerKotlinModule()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin module now automatically registered when using tools.jackson.module.kotlin.jacksonObjectMapper

@JordanJLopez JordanJLopez marked this pull request as ready for review April 3, 2026 20:43
@samuelAndalon samuelAndalon merged commit d1815a1 into master Apr 6, 2026
14 checks passed
@samuelAndalon samuelAndalon deleted the jackson-upgrade branch April 6, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants