How to use LegacyCoercingInputInterceptor in v22 #3594
-
It seems v21 uses this by default, but I can't figure out how to enable the LegacyCoercingInputInterceptor in v22. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
The code that uses this callback is still in place in V22 - but it being on by default has changed the value conversion code does
So you need to place a It will then run that code during value conversion The reason it was removed in the V22 breaking change version is that we wanted to move to a more spec compliant value conversion and the breaking change version was the time to do it. We knew it may hurt some people relying on old value shapes so we pre built this conversion callback to allow people to go back to the old ways if need be |
Beta Was this translation helpful? Give feedback.
-
Since I just struggled for a while with this issue, I'll add my solution. I am using DGS 9.0.3, which in turn uses graphql-java. In order to do this at the global level in spring, you need to do the following:
|
Beta Was this translation helpful? Give feedback.
-
If you're using this library in Spring Boot via spring-graphql, you can use it like this (in Kotlin): class GraphQlInterceptor : WebGraphQlInterceptor {
override fun intercept(request: WebGraphQlRequest, chain: WebGraphQlInterceptor.Chain): Mono<WebGraphQlResponse> {
request.configureExecutionInput { _, builder ->
builder.graphQLContext(mapOf(InputInterceptor::class.java to LegacyCoercingInputInterceptor.migratesValues()))
builder.build()
}
return chain.next(request)
}
}
@Configuration
class GraphQlInterceptorConfig {
@Bean
fun customGraphQlInterceptor(): WebGraphQlInterceptor {
return GraphQlInterceptor()
}
}
|
Beta Was this translation helpful? Give feedback.
The code that uses this callback is still in place in V22 - but it being on by default has changed
the value conversion code does
So you need to place a
LegacyCoercingInputInterceptor
into the requestsgraphql.GraphQLContext
under the keygraphql.execution.values.InputInterceptor
class.It will then run that code during value conversion
The reason it was removed in the V22 breaking change version is that we wanted to move to a more spec compliant value conversion and the breaking change version was the time to do it. We knew it may hurt some people relying on old value shapes so we pre built this conversion c…