Class DataGenerator

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

@Component
public class DataGenerator
extends Object
This sample is not connected to a database : its aim is just to check all the GraphQL schema possibilities, to insure that everything works correctly, from the client to the server.
This class generates the needed data on the fly.
Author:
etienne-sf
  • Field Details

  • Constructor Details

  • Method Details

    • generateInstance

      public <T> T generateInstance​(Class<T> clazzToReturn)
      Generates a new instance of the given class, with all fields containing a random value. If a field is itself a GraphQL Type (and not a Scalar), then all its field are recursively filled.
      Type Parameters:
      T - Any GraphQL type (scalar or not)
      Parameters:
      clazz - A class of a Scalar GraphQL type, or a class of a GraphQL type, as defined in a GraphQL schema.
      Returns:
    • generateInstanceList

      public <T> List<T> generateInstanceList​(Class<T> clazz, int nbItems)
      Returns a list of instances of the given type. The instances are filled by generateInstance(Class)
      Type Parameters:
      T - Any GraphQL type (scalar or not)
      Parameters:
      clazz -
      nbItems - The number of items expected in the returned list
      Returns: