T
- for twopublic interface LightDataFetcher<T> extends TrivialDataFetcher<T>
LightDataFetcher
is a specialised version of DataFetcher
that is passed more lightweight arguments
when it is asked to fetch values. The most common example of this is the PropertyDataFetcher
which does not need
all the DataFetchingEnvironment
values to perform its duties.Modifier and Type | Method and Description |
---|---|
T |
get(GraphQLFieldDefinition fieldDefinition,
java.lang.Object sourceObject,
java.util.function.Supplier<DataFetchingEnvironment> environmentSupplier)
This is called to by the engine to get a value from the source object in a lightweight fashion.
|
get
T get(GraphQLFieldDefinition fieldDefinition, java.lang.Object sourceObject, java.util.function.Supplier<DataFetchingEnvironment> environmentSupplier) throws java.lang.Exception
DataFetchingEnvironment
is wrapped
in a supplier that is only created on demand.
If you are a lightweight data fetcher (like PropertyDataFetcher
is) then you can implement this method to have a more lightweight
method invocation. However, if you need field arguments etc. during fetching (most custom fetchers will) then you should use implement
DataFetcher.get(DataFetchingEnvironment)
.
fieldDefinition
- the graphql field definitionsourceObject
- the source object to get a value fromenvironmentSupplier
- a supplier of the DataFetchingEnvironment
that creates it lazilyDataFetcherResult
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.