Package org.allGraphQLCases.server.impl
Class DataGenerator
java.lang.Object
org.allGraphQLCases.server.impl.DataGenerator
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.
This class generates the needed data on the fly.
- Author:
- etienne-sf
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
generateInstance
(Class<T> clazzToReturn) Generates a new instance of the given class, with all fields containing a random value.<T> List<T>
generateInstanceList
(Class<T> clazz, int nbItems) Returns a list of instances of the given type.
-
Field Details
-
RANDOM
-
-
Constructor Details
-
DataGenerator
public DataGenerator()
-
-
Method Details
-
generateInstance
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
Returns a list of instances of the given type. The instances are filled bygenerateInstance(Class)
- Type Parameters:
T
- Any GraphQL type (scalar or not)- Parameters:
clazz
-nbItems
- The number of items expected in the returned list- Returns:
-