How can I specify an ObjectMapper that has to be used when calling the /graphql endpoint?
I am using spring boot and the graphql-spring-boot-starter dependency version 7.0.1.
I found github issue: https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/97. Where a combination of ObjectMapperConfigurer and schemaParserOptions is mentioned.
However that does not work for me.
I currently have the following JacksonConfig.
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper()
.setDefaultPropertyInclusion(JsonInclude.Include.NON_EMPTY)
.findAndRegisterModules();
}
@Bean
ObjectMapperConfigurer objectMapperConfigurer() {
return (mapper, context) -> mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
}
@Bean
SchemaParserOptions schemaParserOptions() {
return SchemaParserOptions.newOptions()
.objectMapperConfigurer((ObjectMapper mapper, ObjectMapperConfigurerContext context) -> mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL))
.build();
}
}
As you can see I am trying to set a different setting for DefaultPropertyInclusion when calling the \graphql endpoint.
(This is because I want the empty interfaces: [] array to be in the response from the introspection)
However, currently with the above configuration, the ObjectMapper with DefaultPropertyInclusion = NON_EMPTY is still being used when doing the graphql introspection. Instead of the ObjectMapper with DefaultPropertyInclusion = NON_NULL.
Can you help me with how I should configure a custom ObjectMapper for the queries on /graphql?