Package graphql.schema
Interface DataFetcher<T>
-
- Type Parameters:
T
- the type of object returned. May also be wrapped in aDataFetcherResult
- All Known Subinterfaces:
IntrospectionDataFetcher<T>
,LightDataFetcher<T>
,TrivialDataFetcher<T>
- All Known Implementing Classes:
AsyncDataFetcher
,PropertyDataFetcher
,SimpleListConnection
,StaticDataFetcher
@PublicSpi public interface DataFetcher<T>
A data fetcher is responsible for returning a data value back for a given graphql field. The graphql engine uses data fetchers to resolve / fetch a logical field into a runtime object that will be sent back as part of the overall graphqlExecutionResult
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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
get(DataFetchingEnvironment environment)
This is called by the graphql engine to fetch the value.
-
-
-
Method Detail
-
get
T get(DataFetchingEnvironment environment) throws java.lang.Exception
This is called by the graphql engine to fetch the value. TheDataFetchingEnvironment
is a composite context object that tells you all you need to know about how to fetch a data value in graphql type terms.- Parameters:
environment
- this is the data fetching environment which contains all the context you need to fetch a value- 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 aDataFetcher
will eventually be handled by the registeredDataFetcherExceptionHandler
and the related field will have a value ofnull
in the result.
-
-