Package graphql.schema
Interface LightDataFetcher<T>
-
- Type Parameters:
T- for two
- All Superinterfaces:
DataFetcher<T>,TrivialDataFetcher<T>
- All Known Implementing Classes:
PropertyDataFetcher
public interface LightDataFetcher<T> extends TrivialDataFetcher<T>
ALightDataFetcheris a specialised version ofDataFetcherthat is passed more lightweight arguments when it is asked to fetch values. The most common example of this is thePropertyDataFetcherwhich does not need all theDataFetchingEnvironmentvalues to perform its duties.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tget(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.-
Methods inherited from interface graphql.schema.DataFetcher
get
-
-
-
-
Method Detail
-
get
T get(GraphQLFieldDefinition fieldDefinition, java.lang.Object sourceObject, java.util.function.Supplier<DataFetchingEnvironment> environmentSupplier) throws java.lang.Exception
This is called to by the engine to get a value from the source object in a lightweight fashion. Only the field and source object are passed in a materialised way. The more heavy weightDataFetchingEnvironmentis wrapped in a supplier that is only created on demand.If you are a lightweight data fetcher (like
PropertyDataFetcheris) 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 implementDataFetcher.get(DataFetchingEnvironment).- Parameters:
fieldDefinition- the graphql field definitionsourceObject- the source object to get a value fromenvironmentSupplier- a supplier of theDataFetchingEnvironmentthat creates it lazily- Returns:
- a value of type T. May be wrapped in a
DataFetcherResult - Throws:
java.lang.Exception- to relieve the implementations from having to wrap checked exceptions. Any exception thrown from aDataFetcherwill eventually be handled by the registeredDataFetcherExceptionHandlerand the related field will have a value ofnullin the result.
-
-