weixin_39665302
weixin_39665302
2020-12-02 03:02

Customize ObjectMapper / inject custom ObjectMapper

Currently the default Spring ObjectMapper is injected.

But in many applications it is already widely used and cannot be customized for graphql.

In my case a legacy app uses ObjectMapper with setSerializationInclusion(Include.NON_NULL). This will break lot's of graphql clients. But I can't change it, because a lot of stuff within the legacy app relies on that behavior.

该提问来源于开源项目:graphql-java/graphql-java-spring

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39913141 weixin_39913141 5月前

    For Micronaut-GraphQL we introduced a GraphQLJsonSerializer abstraction. Maybe this could inspire graphql-java-spring as well. See https://github.com/micronaut-projects/micronaut-graphql/commit/9a51982a8de01d906216dfa834dae97ed6b3a41c for details.

    点赞 评论 复制链接分享
  • weixin_39594191 weixin_39594191 5月前

    I like the Serializer abstraction mentioned by , I think this is the way to go. Anyone interested in creating a PR? ?

    点赞 评论 复制链接分享
  • weixin_39913141 weixin_39913141 5月前

    I will provide a PR this week.

    点赞 评论 复制链接分享
  • weixin_39594191 weixin_39594191 5月前

    thanks a lot

    点赞 评论 复制链接分享
  • weixin_39594191 weixin_39594191 5月前

    solved via #10

    点赞 评论 复制链接分享
  • weixin_39972777 weixin_39972777 5月前

    when will 2.0 be released?

    点赞 评论 复制链接分享
  • weixin_39913141 weixin_39913141 5月前

    Similar as https://github.com/graphql-java-kickstart/graphql-java-servlet/issues/42

    Maybe something like a GraphQLObjectMapperProvider interface can be introduced which has a GraphQLObjectMapperProvider implementation that simply takes the general ObjectMapper in the application context.

    点赞 评论 复制链接分享
  • weixin_39972777 weixin_39972777 5月前

    yea, there really shouldn't be a hardcoded objectMapper. I'm attempting to implement this in hybris, and am not able to use the Jackson object mapper.

    点赞 评论 复制链接分享

相关推荐