smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

`List<@NonNull String>` should be `[String!]` not `[String!]!`

Open t1 opened this issue 4 years ago • 3 comments

When I add a @NonNull to the element type of a list, the resulting list still should be nullable.

@GraphQLApi
public class Boundary {
	public @Query String foo(List<@NonNull String> strings) {
		return "bar";
	}
}

But it actually becomes:

type Query {
  foo(strings: [String!]!): String
}

t1 avatar Apr 22 '21 14:04 t1

When building the model the information about annotations on the argument and its parameters are merged. ArgumentCreator:

    public Optional<Argument> createArgument(Operation operation, MethodInfo methodInfo, short position) {
     //methodInfo = java.util.List<java.lang.String> foo(java.util.List<@NonNull java.lang.String> list) 
     Annotations annotationsForThisArgument = Annotations.getAnnotationsForArgument(methodInfo, position);
    // annotationsForThisArgument = {org.eclipse.microprofile.graphql.NonNull=@NonNull}
   }

So the book keeping needs to be changed to not merge all annotations on the argument and its parameters. I make an attempt at fixing it.

computerlove avatar May 21 '21 11:05 computerlove

This relates to bug #740 also, as that bug is about Lists nested deeper in the generics structure, and it is related to how is model for GraphQL schema built for collections. At least we have to make sure we do not bring big conflicts when patching this and that bugs.

velias avatar May 24 '21 07:05 velias

Ok, I will wait for your work on #740.

computerlove avatar May 25 '21 06:05 computerlove