Open oos-mxx opened 1 week ago
Thanks, we'll look into this and hope to have an answer within a month or so.
Note that you can also submit a PR directly if you have identified where the issue is located.
Hello, could you provide a more complete code sample to reproduce your problem ? You may also start a PR, even draft, if you have any test case that reproduce it.
I fixed the problem for my concrete TypeFunction Bar
. I had to override TypeFunction#buildType(boolean, Class<?>, AnnotatedType, ProcessingElementsContainer)
to handle the presence of a GraphQLNonNull
annotation.
I found the GraphQLFieldRetriever
having the following method getTypeFunction
:
private TypeFunction getTypeFunction(Method method, ProcessingElementsContainer container) {
graphql.annotations.annotationTypes.GraphQLType annotation = method.getAnnotation(graphql.annotations.annotationTypes.GraphQLType.class);
TypeFunction typeFunction = container.getDefaultTypeFunction();
if (annotation != null) {
typeFunction = newInstance(annotation.value());
}
return typeFunction;
}
For my annotated method foo
this method would not use DefaultTypeFunction
as annotation != null
would apply. Otherwise DefaultTypeFunction
's implementation of buildType
would be executed as follows:
@Override
public GraphQLType buildType(boolean input, Class<?> aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) {
TypeFunction typeFunction = getTypeFunction(aClass, annotatedType);
if (typeFunction == null) {
throw new IllegalArgumentException("unsupported type");
}
GraphQLType result = typeFunction.buildType(input, aClass, annotatedType, container);
if (annotatedType != null && annotatedType.isAnnotationPresent(GraphQLNonNull.class)) {
result = new graphql.schema.GraphQLNonNull(result);
}
return result;
}
I copied this behaviour in my Bar#buildType
method, which resulted in a non-null input field in the schema.
Now I'm not sure if this is the intended way to do for concrete implementations or should be concerned by maybe GraphQLFieldRetriever
.
The following is a simplified version of my problem.
I have an input class
MyInput
likeThe created schema does not define
foo
as non-null:If I remove the
@GraphQLType
annotation the contained input looks like that:Note:
Foo
is the data type of a field in several classes (sayMyInputOne
,MyInputTwo
, ...) in my application. The GraphQL interface should use specific enums (BarOne
orBarTwo
...) as data types for each class.