Provides the data fetching environment for closures. Available as the second parameter to dataFetcher closures provided by custom properties. The main purpose of this class is to provide the ability to get fetch arguments for custom properties with a return type that is a domain class. This allows the same query efficiency that is provided by the generic data fetchers by default. Usage:
class Foo {
static graphql = GraphQLMapping.build {
add('bar', Bar) {
dataFetcher { Foo foo, ClosureDataFetchingEnvironment env ->
//The fetchArguments will be populated based on what properties
//were requested from the 'bar'
Bar.where {
.list(env.fetchArguments)
}
}
}
}
}
Type | Name and description |
---|---|
DataFetchingEnvironment |
environment |
Constructor and description |
---|
ClosureDataFetchingEnvironment
(DataFetchingEnvironment environment, java.lang.Class domainType) |
Type Params | Return Type | Name and description |
---|---|---|
|
java.util.Map |
getFetchArguments(java.lang.String projectedProperty = null) For use with domain class return types only. |
|
java.util.Set<java.lang.String> |
getJoinProperties(java.lang.String projectedProperty = null) Which properties should be joined in the subsequent query. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
For use with domain class return types only. All other invocations will return null.
projectedProperty
- The property name being projected on in the queryWhich properties should be joined in the subsequent query. Based upon which fields were requested to be returned by the end user.
projectedProperty
- The property name being projected on in the query