Skip to content
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

Scalars containing an Instant cannot be serialized over subscription #488

Open
Survival1sm opened this issue Mar 1, 2024 · 0 comments
Open

Comments

@Survival1sm
Copy link

When an object containing an Instant is sent over the subscription as a non-scalar (List), the Instant is converted to a string by graphql prior to jackson, and is able to be serialized by ApolloMessages within the jsonMessage method.

When the object is sent over the subscription as a scalar (Map_String_ObjectWithInstant), the Instant retains its data type up to jackson, and since the object mapper in ApolloMessages does not have the JavaTimeModule registered, it can no longer be serialized and produces the following exception:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.Instant not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling

Originating from AplloMessages:71

image

I resolved the issue by creating my own PerConnectionApolloHandler bean, and providing duplicate implementations of PerConnectionApolloHandler, ApolloProtocolHandler, and finally ApolloMessages with the updated object mapper.

Do we have a better way to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant