Skip to content

JsonMappingException: No serializer found for class graphql.execution.TypeInfo #37

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

Closed
zash80 opened this issue Jul 18, 2017 · 3 comments

Comments

@zash80
Copy link

zash80 commented Jul 18, 2017

The following exception is thrown writing GraphQL execution result with errors to response:

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class graphql.execution.TypeInfo and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.HashMap["errors"]->java.util.ArrayList[0]->graphql.execution.NonNullableFieldWasNullException["typeInfo"])
	at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:284) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1110) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1135) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:633) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:536) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:30) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3681) ~[jackson-databind-2.8.8.jar:2.8.8]
	at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3057) ~[jackson-databind-2.8.8.jar:2.8.8]
	at graphql.servlet.GraphQLServlet.query(GraphQLServlet.java:281) [graphql-java-servlet-4.1.0.jar:na]
	at graphql.servlet.GraphQLServlet.query(GraphQLServlet.java:264) [graphql-java-servlet-4.1.0.jar:na]
	at graphql.servlet.GraphQLServlet.lambda$new$1(GraphQLServlet.java:185) [graphql-java-servlet-4.1.0.jar:na]
	at graphql.servlet.GraphQLServlet.doRequest(GraphQLServlet.java:222) [graphql-java-servlet-4.1.0.jar:na]
	at graphql.servlet.GraphQLServlet.doPost(GraphQLServlet.java:240) [graphql-java-servlet-4.1.0.jar:na]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [javax.servlet-api-3.1.0.jar:3.1.0]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
`


Here a NonNullableFieldWasNullException containing a TypeInfo field is going to be serialized without matching Jackson Serializer.
@luoruici
Copy link

+1

@apottere
Copy link
Contributor

I'll take a look

@apottere
Copy link
Contributor

apottere commented Aug 24, 2017

It looks like this is because in graphql-java 3.0.0, the getters in TypeInfo don't start with "get", they're just the names of the field: https://github.com/graphql-java/graphql-java/blob/v3.0.0/src/main/java/graphql/execution/TypeInfo.java

The class was renamed to ExecutionTypeInfo and the getters are fixed on the current master: https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/ExecutionTypeInfo.java

I'll provide a custom serializer for now, but it should be fixed in 4.0.0 and I'll remove the custom serializer then.

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

3 participants