Class DataFetcherImpl

java.lang.Object
com.graphql_java_generator.plugin.language.impl.DataFetcherImpl
All Implemented Interfaces:
DataFetcher

public class DataFetcherImpl extends Object implements 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 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 Details

    • DataFetcherImpl

      public DataFetcherImpl(Field field, DataFetchersDelegate dataFetcherDelegate, boolean declareInGraphQLProvider, boolean completableFuture, Type graphQLOriginType)
      Parameters:
      field - The field that this data fetcher must fill
      dataFetcherDelegate - The DataFetchersDelegate that contains this data fetcher. This constructor attached the newly created data fetcher into the given DataFetchersDelegate
      declareInGraphQLProvider - 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 the DataFetchersDelegate should 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 the DataFetchersDelegate.
      completableFuture - indicates that this DataFetcher will be actually loaded later, with the help of a BatchLoader.
      graphQLOriginType - The origin of this DataFetcher, that is: the name of the object which contains the field to fetch.
      There are two kinds of DataFetcher:
      • DataFetcher for fields of object, interface(...). These DataFetcher need 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.
      • DataFetcher for query/mutation/subscription. In these case, the field that is fetched by this DataFetcher has no origin: it's the start of the request.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: DataFetcher
      The 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:
      getName in interface DataFetcher
      Returns:
    • getCamelCaseName

      public String getCamelCaseName()
      The name of the DataFetcher, in camelCase.
      Specified by:
      getCamelCaseName in interface DataFetcher
      Returns:
      See Also:
    • getPascalCaseName

      public String getPascalCaseName()
      The name of the DataFetcher, in PascalCase.
      Specified by:
      getPascalCaseName in interface DataFetcher
      Returns:
      See Also: