Class DataFetcherImpl
java.lang.Object
com.graphql_java_generator.plugin.language.impl.DataFetcherImpl
- All Implemented Interfaces:
DataFetcher
This class represents a GraphQL Data Fetcher. It's a piece of code which responsability is to read non scalar fields
on GraphQL objects, which includes: all fields for queries, mutations and subscriptions, and all non scalar fields
for regular GraphQL objects.
They are grouped into
Its characteristics are read by
The arguments for the data fetcher are the arguments of its source field in the GraphQL schema.
They are grouped into
DataFetchersDelegates (see DataFetchersDelegate doc for more information on
that).Its characteristics are read by
GenerateCodeDocumentParser, and used by GenerateCodeGenerator and the
Velocity templates to generate the code of the DataFechers, and their declaration in the GraphQLProvider.The arguments for the data fetcher are the arguments of its source field in the GraphQL schema.
- Author:
- etienne-sf
-
Constructor Summary
ConstructorsConstructorDescriptionDataFetcherImpl(Field field, DataFetchersDelegate dataFetcherDelegate, boolean declareInGraphQLProvider, boolean batchMapping, boolean withDataLoader, Type graphQLOriginType) -
Method Summary
Modifier and TypeMethodDescriptionThe name of the DataFetcher, in camelCase.getName()The name of the DataFetcher: it's actually the field name, as read in the GraphQL schema.The name of the DataFetcher, in PascalCase.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.graphql_java_generator.plugin.language.DataFetcher
getDataFetchersDelegate, getField, getGraphQLOriginType, getJavaName, isBatchMapping, isWithDataLoader
-
Constructor Details
-
DataFetcherImpl
public DataFetcherImpl(Field field, DataFetchersDelegate dataFetcherDelegate, boolean declareInGraphQLProvider, boolean batchMapping, boolean withDataLoader, Type graphQLOriginType) - Parameters:
field- The field that this data fetcher must filldataFetcherDelegate- TheDataFetchersDelegatethat contains this data fetcher. This constructor attached the newly created data fetcher into the givenDataFetchersDelegatedeclareInGraphQLProvider- true if this data fetcher must be declared to the graphql-java framework. This value is generally true. It should be false only when two data fetchers of the same exist, for instance when theDataFetchersDelegateshould implement one such data fetcher with a data loader and one without. In this case, one data fetcher is registered in the GraphQLProvider. And this data fetcher is also declared in the GraphQLDataFetchers class, and is responsible to all the relevant method in theDataFetchersDelegate.batchMapping- Indicates if this DataFetcher should be annotated with the@BatchMappingannotation. This is controlled by thegenerateBatchMappingDataFetchersplugin parameterwithDataLoader- indicates that this DataFetcher will be actually loaded later, with the help of aBatchLoader.graphQLOriginType- The origin of thisDataFetcher, that is: the name of the object which contains the field to fetch.
There are two kinds ofDataFetcher:DataFetcherfor fields of object, interface(...). TheseDataFetcherneed to have access to the object instance, that contains the field (or attribute) it fetches. This instance is the orgin, and will be a parameter in the DataFetcher call, that contains the instance of the object, for which this field is fetched.DataFetcherfor query/mutation/subscription. In these case, the field that is fetched by thisDataFetcherhas no origin: it's the start of the request.
-
-
Method Details
-
getName
Description copied from interface:DataFetcherThe name of the DataFetcher: it's actually the field name, as read in the GraphQL schema. This name is a valid java classname identifier, and is the name to use as a method name. For instance, for the field human.friends, the DataFetcher name is Human.- Specified by:
getNamein interfaceDataFetcher- Returns:
-
getCamelCaseName
The name of the DataFetcher, in camelCase.- Specified by:
getCamelCaseNamein interfaceDataFetcher- Returns:
- See Also:
-
getPascalCaseName
The name of the DataFetcher, in PascalCase.- Specified by:
getPascalCaseNamein interfaceDataFetcher- Returns:
- See Also:
-