Working with graphql-spqr and Spring Boot, I’m trying to run the project but I run into this:
exception:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema' defined in class path resource [io/leangen/graphql/spqr/spring/autoconfigure/SpqrAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; nested exception is io.leangen.graphql.metadata.exceptions.TypeMappingException: Multiple methods detected for operation "defaultInstanceForType" with different return types. Types found: [com.google.protobuf.Message, com.google.protobuf.MessageLite]. If this is intentional, and you wish GraphQL SPQR to infer the most common super type automatically, see https://github.com/leangen/graphql-spqr/wiki/Errors#operation-with-multiple-resolver-methods-of-different-types
and I got redirected to this for help : https://github.com/leangen/graphql-spqr/wiki/Errors#operation-with-multiple-resolver-methods-of-different-types
I was not having multiple methods with the same name which triggers me, the URL in the exception is not helpful and can’t even be edited or commented.
Advertisement
Answer
Removing the protobuf Timestamp fields fix the problem!
After changing my return Object it worked out, I had to refactor com.google.protobuf.Timestamp
to Date, LocalDate or even String and it works perfectly.