Class DataFetchersDelegateBoardImpl

java.lang.Object
org.forum.server.specific_code.DataFetchersDelegateBoardImpl
All Implemented Interfaces:
DataFetchersDelegateBoard

@Component public class DataFetchersDelegateBoardImpl extends Object implements DataFetchersDelegateBoard
This class implements the access to the database : there are so many ways to do this, that the developper has still work to do. But all the GraphQL boilerplate is generated.
The GraphQLDataFetchersDelegate interface is generated from the given schema
Author:
etienne-sf
  • Field Details

    • logger

      protected org.slf4j.Logger logger
      The logger for this instance
  • Constructor Details

    • DataFetchersDelegateBoardImpl

      public DataFetchersDelegateBoardImpl()
  • Method Details

    • topics

      public List<Topic> topics(graphql.schema.DataFetchingEnvironment dataFetchingEnvironment, Board source, Date since)
    • topics

      public Object topics(graphql.schema.DataFetchingEnvironment dataFetchingEnvironment, org.dataloader.DataLoader<Long,Topic> dataLoader, Board origin, Date since)
      Description copied from interface: DataFetchersDelegateBoard
      This method loads the data for Board.topics. It may return whatever is accepted by the Spring Controller, that is:
      • A resolved value of any type (typically, a List<org.forum.server.graphql.Topic>)
      • Mono and Flux for asynchronous value(s). Supported for controller methods and for any DataFetcher as described in Reactive DataFetcher. This would typically be a Mono<List<org.forum.server.graphql.Topic>> or a Flux<List<org.forum.server.graphql.Topic>>
      • Kotlin coroutine and Flow are adapted to Mono and Flux
      • java.util.concurrent.Callable to have the value(s) produced asynchronously. For this to work, AnnotatedControllerConfigurer must be configured with an Executor. This would typically by a Callable<List<org.forum.server.graphql.Topic>>
      As a complement to the spring-graphql documentation, you may also return:
      • A CompletableFuture<?>, for instance CompletableFuture<List<org.forum.server.graphql.Topic>>. This allows to use graphql-java java-dataloader to highly optimize the number of requests to the server. The principle is this one: The data loader collects all the data to load, avoid to load several times the same data, and allows parallel execution of the queries, if multiple queries are to be run.
      • A Publisher (instead of a Flux), for Subscription for instance
      Specified by:
      topics in interface DataFetchersDelegateBoard
      Parameters:
      dataFetchingEnvironment - The GraphQL DataFetchingEnvironment. It gives you access to the full GraphQL context for this DataFetcher
      dataLoader - The DataLoader allows to load several data in one query. It allows to solve the (n+1) queries issues, and greatly optimizes the response time.
      You'll find more informations here: https://github.com/graphql-java/java-dataloader
      origin - The object from which the field is fetch. In other word: the aim of this data fetcher is to fetch the topics attribute of the origin, which is an instance of {ObjectType {name:Board, fields:{Field{name:id, type:ID!, params:[]},Field{name:name, type:String!, params:[]},Field{name:publiclyAvailable, type:Boolean, params:[]},Field{name:topics, type:[Topic]!, params:[since:Date]}}, comments ""}. It depends on your data modle, but it typically contains the id to use in the query.
      since - The input parameter sent in the query by the GraphQL consumer, as defined in the GraphQL schema.