T
- the type of object returned. May also be wrapped in a DataFetcherResult
@PublicSpi public interface DataFetcher<T>
ExecutionResult
In other implementations, these are sometimes called "Resolvers" or "Field Resolvers", because that is there function,
they resolve a logical graphql field into an actual data value.Modifier and Type | Method and Description |
---|---|
T |
get(DataFetchingEnvironment environment)
This is called by the graphql engine to fetch the value.
|
default boolean |
isTrivialDataFetcher()
If a data fetcher is simply mapping data from an object to a field, it can be considered a trivial data fetcher for the purposes
of tracing and so on.
|
T get(DataFetchingEnvironment environment) throws java.lang.Exception
DataFetchingEnvironment
is a composite
context object that tells you all you need to know about who to fetch a data value in graphql type terms.environment
- this is the data fetching environment which contains all the context you need to fetch a valueDataFetcherResult
java.lang.Exception
- to relieve the implementations from having to wrap checked exceptions. Any exception thrown
from a DataFetcher
will eventually be handled by the registered DataFetcherExceptionHandler
and the related field will have a value of null
in the result.default boolean isTrivialDataFetcher()