Different naming strategies in spring boot project for Rest and GraphQL APIs

Viewed 99

I have a spring boot project with different Rest APIs and GraphQL APIs. Since the Rest APIs work with some old services, I need to set spring.jackson.property-naming-strategy to CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES. However, my GraphQL schemes work with the default naming strategy. It worked fine with graphql-java-tools v5. But after updating it to v12, the naming strategy for GraphQL schemes has also changed.

For example, a field with the name userId could be reached in Rest APIs with the name user_id and in the GraphQL APIs with the name userId. Now, both of them must be reached with the name user_id.

Since I can't change other services which use these APIs, I need to change the naming strategy for GraphQL. I tried @JsonNaming annotation to change the strategy for some classes, however, there are classes that are used in both APIs, so I can't use this for every class in my GraphQL requests and responses.

I could not find any config to change this naming strategy only for GraphQL. I also could not change the default property data fetcher in GraphQL, because I'm not sure how it works.

0 Answers
Related