Comments (7)
Are you using 3.9.0? I released this change yesterday which should support that: fff13ab
from graphql-spring-boot.
Yes, I am. I've just debugged the bootstrapping of the application and I do see that my configuration is being applied to the object mapper. So, answering my own question, configuration works just fine. I'll close the issue now and if relevant I'll post here (for reference) how I solved my problem.
from graphql-spring-boot.
A bit more debugging shows that the object mapper used to deserialise inputs from mutations is not the same as the one I configured via a bean in the Application
class.
When I debug the bootstrapping of the application I see that the module JavaTimeModule
is added to a object mapper that already contains the Jdk8Module
(as expected).
Before my configuration is applied:
After my configuration is applied:
However, when handling the input of a mutation the object mapper is different (with a different memory address) and no longer has the JavaTimeModule
.
from graphql-spring-boot.
It seems that the object mapper that deserialises the values passed into the mutation is not the one in the servlet but instead it's the one in com.coxautodev.graphql.tools.MethodFieldResolver
. java-graphql-tools
also has it's own ObjectMapperConfigurer
abstraction.
from graphql-spring-boot.
I've fixed my problem (deserialising LocalDateTime objects passed in as inputs to mutations) by also registering a bean to configure the object mapper used by java-graphql-tools
(which I use to parse the schema definition).
So the final configuration looks like this:
@SpringBootApplication
public class Application {
(...)
@Bean
ObjectMapperConfigurer objectMapperConfigurer() {
return (ObjectMapper mapper) -> mapper.registerModule(new JavaTimeModule());
}
@Bean
SchemaParserOptions schemaParserOptions() {
return SchemaParserOptions.newOptions()
.objectMapperConfigurer((ObjectMapper mapper, ObjectMapperConfigurerContext context) -> mapper.registerModule(new JavaTimeModule()))
.build();
}
(...)
}
from graphql-spring-boot.
Ah, yeah. The servlet object mapper handles parsing variables and output, but the graphql-java-tools objectmapper handles marshalling the field input values to java types. It's a little wonky, but since the two libraries can be used independently I'm not sure how to make it better.
from graphql-spring-boot.
It's indeed a difficult one to solve elegantly. If the interfaces for the ObjectMapperConfigurer
in both projects would align, then it would be possible to create one configuration bean that would get injected in both sides. It wouldn't be super elegant, but a least would remove the need to configure things twice.
Thanks again for being so active in giving support 👍
from graphql-spring-boot.
Related Issues (20)
- Customize SimpleDataFetcherExceptionHandler to avoid logException for certain errors HOT 1
- Spring Boot Graphql Remove duplicates from the Response
- SpringDoc bean name conflict error HOT 1
- Latest 15.0.0 version is not compatible with Spring boot 3.0.2 and spring security 6.0.1 HOT 3
- Possibility to add authorization headers to the GraphQLTestSubscription HOT 14
- How to set the bearer token dynamically in graphql-spring-boot playground
- different data response for nullable and non-nullable responses
- @connection not working after Spring Boot and graphql upgrade HOT 1
- CVE-2023-28867 affects all recent versions (including v15)
- `ErrorHandlerSupplier` not always initialized when we first need it
- Query returning the result of previously timed out query
- Support check origin for websocket to secure against cross-site attacks
- Support CSRF on websockets to secure against cross-site attacks
- When upgrading to Spring Boot 3.1.0 we get in the response the tracing information under extensions HOT 2
- MetricsInstrumentation does not implement updated API of TracingInstrumentation provided by graphql-java
- Maven seems to confuse graphql-java version HOT 4
- Request scoped beans aren't accessible in mutation and query resolvers
- Virtual threads support
- Cannot disable tracing response with graphql-spring-boot-starter version 15 HOT 4
- No qualifying bean of type 'com.graphql.spring.boot.test.GraphQLTestTemplate' available : graphql-spring-boot-starter-test:jar:15.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-spring-boot.