leangen / graphql-spqr

Build a GraphQL service in seconds
Apache License 2.0
1.09k stars 179 forks source link

Custom descriptions for nested fields are not showing #418

Closed nimi-kaushal closed 1 year ago

nimi-kaushal commented 2 years ago

I'm having issue of custom descriptions for nested fields are not showing even though descriptions are added as @GraphQLQuery descriptions.

baohouse commented 2 years ago

Here is an example.

@GraphQLMutation(name = "saveCompay", description = "Saves a company.")
public CompanyDto saveCompany(
  @GraphQLArgument(name = "input", description = "The company data to save.") @GraphQLNonNull final CompanyDto input,
  @GraphQLEnvironment final ResolutionEnvironment resolutionEnvironment) {
  return execSaveCompany(input, resolutionEnvironment);
}
@GraphQLType(name = "Company", description = "Represents a business")
public class CompanyDto extends OrganizationDto {

  @GraphQLQuery(description = "An easier to read name for the company")
  private String friendlyName;

  @GraphQLQuery(description = "If the company does business under a different name")
  private String dba;

}

The resulting schema is:

"""Saves a company."""
saveCompany(
  """The company data to save."""
  input: CompanyInput!
): Company

"""
Represents a business.
"""
input CompanyInput {
  dba: String
  friendlyName: String
}

Notice there is no description showing in the schema under CompanyInput.

baohouse commented 1 year ago

We figured out the problem... we had to have separate annotations on the getter and setter, e.g.

@GraphQLQuery(description = FIELD_DESCRIPTION_DBA)
public String getDba() {
  return dba;
}

@GraphQLInputField(description = FIELD_DESCRIPTION_DBA)
public void setDba(final String dba) {
  this.dba = dba;
}
kaqqao commented 1 year ago

Yes, this is correct. Sorry for not responding.