Class MyQueryTypeController

java.lang.Object
org.allGraphQLCases.server.MyQueryTypeController
org.allGraphQLCases.server.impl.MyQueryTypeController

@Controller @SchemaMapping(typeName="MyQueryType") public class MyQueryTypeController extends MyQueryTypeController
This class is used to check that the overriding of a Spring Controller actually works at runtime, so it must be checked on client side. To do this, one of the returned strings is changed.
  • Constructor Details

    • MyQueryTypeController

      public MyQueryTypeController()
  • Method Details

    • checkOverriddenController

      @SchemaMapping(field="checkOverriddenController") public String checkOverriddenController(graphql.schema.DataFetchingEnvironment dataFetchingEnvironment)
      Description copied from class: MyQueryTypeController
      This method loads the data for ${dataFetcher.graphQLType}.checkOverriddenController.
      For optimization, this method returns a CompletableFuture. 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.
      You can implements this method like the sample below:
       @Override
       public CompletableFuture<List> friends(DataFetchingEnvironment environment,
                      DataLoader<Long, Member> dataLoader, Human origin) {
              List<java.lang.Long> friendIds = origin.getFriendIds();
              DataLoader<java.lang.Long, CharacterImpl> dataLoader = environment.getDataLoader("Character");
              return dataLoader.loadMany(friendIds);
       }
       

      Overrides:
      checkOverriddenController in class MyQueryTypeController
      Parameters:
      dataFetchingEnvironment - The GraphQL DataFetchingEnvironment. It gives you access to the full GraphQL context for this DataFetcher