为GraphQL

问题描述

如何在调用ObjectMapper端点时指定必须使用的/graphql

我正在使用Spring Boot和graphql-spring-boot-starter依赖版本7.0.1

我发现github问题:https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/97。提到ObjectMapperConfigurerschemaParserOptions的组合。 但是,这对我不起作用。

我目前有以下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();
    }
}

如您所见,调用DefaultPropertyInclusion端点时,我试图为\graphql设置不同的设置。 (这是因为我希望空的interfaces: []数组出现在内省的响应中)

但是,当前具有以上配置,在进行graphql自省时,仍使用DefaultPropertyInclusion = NON_EMPTY的ObjectMapper。代替DefaultPropertyInclusion = NON_NULL的ObjectMapper。

您能帮助我为/graphql上的查询配置自定义ObjectMapper吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)