-
Notifications
You must be signed in to change notification settings - Fork 182
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
Schema generation fails in the presence of a java.time.OffsetTime attribute #260
Comments
You're right, In general, if you run into a type that doesn't work out of the box, you must register a custom For scalars (like public class OffsetTimeMapper implements TypeMapper {
private final GraphQLScalarType GraphQLOffsetTime = Scalars.temporalScalar(OffsetTime.class, "OffsetTime", "a time with a UTC offset",
OffsetTime::parse, i -> OffsetTime.ofInstant(i, ZoneOffset.UTC));
@Override
public GraphQLOutputType toGraphQLType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) {
return GraphQLOffsetTime;
}
@Override
public GraphQLInputType toGraphQLInputType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) {
return GraphQLOffsetTime;
}
@Override
public boolean supports(AnnotatedType type) {
return ClassUtils.isSuperClass(OffsetTime.class, type);
}
} Register via: generator.withTypeMappers(new OffsetTimeMapper()); |
Hi! Thanks for your answer, I tested my use case with the last snapshot and it works perfectly. Looking forward to the next release. However, I run into a small problem with your proposed custom TypeMapper implementation since ClassUtils.isSupperClass does not exist for v0.9.9. I modified the code simply replacing that call by what's now in master. @Override
public boolean supports(AnnotatedType type) {
return OffsetTime.class.isAssignableFrom(GenericTypeReflector.erase(type.getType()));
} |
Hello,
I have this simple POJO:
Which is used as return type of a simple GraphqlQuery annotated method
SPQR doesn't seem to be able to handle the OffsetTime attribute and throws this exception:
I wonder if there is any workaround for this issue, if I am missing some kind of configuration or if it can be related to the usage of the spring boot starter.
Thanks in advance
The text was updated successfully, but these errors were encountered: