-
Notifications
You must be signed in to change notification settings - Fork 96
Description
I've noticed that GraphQL will, for fields starting with "is" (e.g. isAvailable), set the DataFetcher to FieldDataFetcher as opposed to PropertyDataFetcher.
Native boolean fields starting by "isXxxx" are allowed to have a getter method of the same name as defined in the Java Beans spec section 8.3.2:
public boolean is<PropertyName>();The same is not necessarily true for Boolean object types.
Although it is discussible if such fields should be using FieldDataFetcher by default, the graphql-java-annotations should allow graphql fields to be easily overwritten by another DataFetcher basic type.
The current case generates a FieldDataFetcher by default:
@ApiModelProperty(value = "")
@GraphQLField
var isAvailable: Boolean? = nullBut instead I would like it to use the PropertyDataFetcher:
@ApiModelProperty(value = "")
@GraphQLField
@GraphQLDataFetcher(PropertyDataFetcher::class)
var isAvailable: Boolean? = nullAnd this code fails to compile because PropertyDataFetcher annotation does not have a public default constructor. To get around it I had to specialize the PropertyDataFetcher for that specific field and it can become quite repetitive having to do the same for other similar fields.
Instead, it would be nice to allow to pass argument for a given specialized constructor as in:
@GraphQLDataFetcher(value=PropertyDataFetcher::class, args="isAvailable")
public Boolean isAvailable = null