grooviter / gql

Groovy GraphQL library
http://grooviter.github.io/gql/
Apache License 2.0
49 stars 6 forks source link

Fetcher closure requires to return explicitly Object #8

Closed mariogarcia closed 7 years ago

mariogarcia commented 7 years ago

The signature of adding a fetcher as a closure is the following:

FieldBuilder fetcher(Closure<Object> fetcher)

The closure returns an object because a data fetcher could return any kind of type.

The problem is that when our closure returns something other that Object the static compilation complains because the type returned is not explicitly casted as an object. Despite the fact that it should work because every object is eventually an object, the generic argument should be removed in order not to be checked by the static compilation, and therefore to be able to return anything it wants.

FieldBuilder fetcher(Closure fetcher)

or maybe

FieldBuilder fetcher(Closure<?> fetcher)