-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure Jackson codec specifically for GraphQL HTTP endpoints #860
Comments
After investigation I compared two responses:
In the not working implementation This is related to the problem, that Jackson is not serializing empty lists. The question is, how can I configure the object mapper for the GraphQL? |
I think this is the expected behavior so far in Spring Boot and Spring for GraphQL - the same Jackson codec/message converter is used for all web endpoints. In Spring Boot, changing There would be one way to configure a Jackson Decoder dedicated to a particular media type, here I'll leave this opened for now so that we can discuss this within the team. |
We've discussed this further internally. Currently, HTTP handlers rely on the web framework to (de)serialize to/from maps of data, so it shares the setup with any web endpoint. To make it independent, we would need to change them to take an |
On a high graphql protocol level because I have no context of spring boot but I want our web tooling and LSP server to work for sprint boot graphql users, are you saying that the Edit: Upon re-reading the http spec, this is completely missing! We should make this content type the default for graphiql. I wonder @rstoyanchev now that I understand the issue better (graphiql being out of date with the http spec 😆 ), if this is indeed the bug, what happens if you add to |
Again, I have 0 context on this probably incredible framework, but from my understanding, if this is about adopting the new spec compliant content type for introspection, then this is a bug entirely on GraphiQL's end (still sending the old |
Hello @acao ! As for the adoption of the new content type, it is really up to you to consider the draft spec, its timeline and your user base. |
This is now fixed in 1.3.0-SNAPSHOTs. Applications can configure Here is an example of how to configure a vanilla @Bean
public GraphQlHttpHandler graphQlHttpHandler(WebGraphQlHandler graphQlHandler) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(new ObjectMapper());
return new GraphQlHttpHandler(graphQlHandler, converter);
} And now with WebFlux: @Bean
public GraphQlHttpHandler graphQlHttpHandler(WebGraphQlHandler webGraphQlHandler) {
ObjectMapper mapper = new ObjectMapper();
CodecConfigurer configurer = ServerCodecConfigurer.create();
configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper));
configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper));
return new GraphQlHttpHandler(webGraphQlHandler, configurer);
} |
Thank you for the update. |
@acao from our perspective this is now solved. I'm not sure if there's anything to do in GraphiQL or graphql-js. In this case, the server is responding without the If those bits are always required by the spec, then this is only an issue on our end. If the spec allows those properties to be missing, then maybe graphql-js could be more lenient about that. I'm not sure where this information can be found - in any case I'll defer to you. Thanks for maintaining graphiql! |
I tried to open the issue here but I was forwarded back to spring boot.
Version: Spring Boot 3.1.5
Current Behavior
I am using
graphiql
withspring-boot-graphql-starter
, however I am getting an error even with the simple schema. Can you please verify what is wrong with the response from introspection? Thank you.Schema:
Error:
Response from call for instrospection:
Response Details
Expected Behavior
Schema explorer should work
The text was updated successfully, but these errors were encountered: