leangen / graphql-spqr-spring-boot-starter

Spring Boot 2 starter powered by GraphQL SPQR
Apache License 2.0
275 stars 68 forks source link

Description for mutation parameters are empty in graphql playground #131

Closed Manivannan-Kannan closed 1 year ago

Manivannan-Kannan commented 1 year ago

Hi,

We have PersonInfo data type(the generated type is PersonInfoInput) and we provided description for all fields. But, when we check it in the graphql playground the descriptions are empty for all the fields. The java classes are below,

PersonInfo.java


@Data @InputStringValidation @Accessors(chain = true) public class PersonInfo {

@GraphQLNonNull
@Size(max = 40)
@GraphQLQuery(description = "Indicates the unique name of the person to identify the address.")
private String displayValue;

@GraphQLNonNull
@Valid
@GraphQLQuery(description = "Indicates the address in multiple languages.")
private List<Description> descriptions;

}

Mutation

@GraphQLMutation(name = "createAddress", description = "Create Address")
public Assessment createAssessment(@GraphQLArgument(name = "createAddress",
    description = "The mutation create address for given person") @Valid PersonInfo personInfo,
        @GraphQLEnvironment ResolutionEnvironment env) {
    return assessmentService.createAssessment(env, personInfo);
}

When we hit /graphiql page and the descriptions for fields in PersonInfoInput type are empty.

We downloaded SDL and we could see the descriptions are empty for PersonInfoInput type alone as below,

'#' input PersonInfoInput { descriptions: [DescriptionInput]! displayValue: String! }

'# A connection to a list of items.' type DataConnection { '# a list of edges' edges: [DataEdge]

' # details about this specific page' pageInfo: PageInfo! totalCount: Long! }


Can you provide any pointer to fix this issue?

Thanks, Manivannan

kaqqao commented 1 year ago

Every time someone reports an issue like this, Lombok is always involved. I suspect the issue is @accessors(chain = true) (specifically the chain=true part), because what it generates are not actually setters, as specified in the JavaBeans spec and, as a result, the fields are not correlated with the setters and end up ignored. But I'm really not sure. Lombok does wild stuff. If you want to support this style, you would likely have to implement a custom InputFieldBuilder.

Manivannan-Kannan commented 1 year ago

Followed https://github.com/leangen/graphql-spqr/issues/418 to fix the above issue.

kaqqao commented 1 year ago

Yes, if you can make it add input field annotations to the generated setters, that also works