Skip to content

Scalars containing an Instant cannot be serialized over subscription #488

Description

@Survival1sm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions