Interface DataFetcher

All Known Implementing Classes:
DataFetcherImpl

public interface DataFetcher
This class represents a GraphQL Data Fetcher. It's a piece of code that reads 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).
Author:
etienne-sf
  • Method Details

    • getName

      String getName()
      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.
      Returns:
    • getJavaName

      default String getJavaName()
      The name of the DataFetcher, as it can be used in the Java code. If the name is a java keyword (class, default, break...), the java name it prefixed by an underscore.
      Returns:
      The name of the DataFetcher, as it can be used in Java code
    • getCamelCaseName

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

      String getPascalCaseName()
      The name of the DataFetcher, in PascalCase.
      Returns:
      See Also:
    • getField

      Field getField()
      Retrieves the Field that this data fetcher fills. The arguments for the data fetcher are the arguments of its field.
      Returns:
    • getDataFetchersDelegate

      DataFetchersDelegate getDataFetchersDelegate()
      Retrieves the DataFetchersDelegate in which this Data Fetcher is implemented
      Returns:
    • getGraphQLOriginType

      Type getGraphQLOriginType()
      Retrieves the origin of this DataFetcher, that is: the name of the object which contains the fields 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.
      Returns:
      the GraphQL name of the type that contains this field, or null if this is a request ()
    • isCompletableFuture

      boolean isCompletableFuture()
      Returns true if this DataFetcher returns a CompletableFuture, which will be used within a graphql-java java-dataloader to optimize the accesses to the database.
      For instance, the DataDetcher would return CompletableFuture<List> (if completableFuture is true) or List (if completableFuture is false).
      Returns: