Class BaseSpqrSchemaGenerator

java.lang.Object
io.leangen.graphql.GraphQLSchemaGenerator
io.jmix.graphql.spqr.BaseSpqrSchemaGenerator
Direct Known Subclasses:
SpqrSchemaGenerator

public class BaseSpqrSchemaGenerator extends io.leangen.graphql.GraphQLSchemaGenerator

This class is the main entry point to the library. It is used to generate a GraphQL schema by analyzing the registered classes and exposing the chosen methods as GraphQL queries or mutations. The process of choosing the methods to expose is delegated to ResolverBuilder instances, and a different set of builders can be attached to each registered class. One such coupling of a registered class and a set of builders is modeled by an instance of OperationSource. Methods of the with*OperationSource family are used to register sources to be analyzed.

Builders can also be registered globally (to be used when none are provided explicitly) via withResolverBuilders(ResolverBuilder...). The process of mapping the Java methods to GraphQL queries/mutations will also transparently map all encountered Java types to corresponding GraphQL types. The entire mapping process is handled by an instance OperationMapper where actual type mapping is delegated to different instances of TypeMapper.

To customize the mapping process, clients can registers their own TypeMappers using withTypeMappers(TypeMapper...). Runtime conversion between values provided by the GraphQL client and those expected by Java code might be needed. This is handled by InputConverter instances.

Similarly, the conversion between values returned by Java code and those expected by the GraphQL client (if needed) is handled by OutputConverter instances. Custom implementations of both InputConverter and OutputConverter can be provided using withInputConverters(InputConverter[]) and withOutputConverters(OutputConverter[]) respectively.

Example:

 
 UserService userService = new UserService(); //could also be injected by a framework
 GraphQLSchema schema = new GraphQLSchemaGenerator()
      .withOperationsFromSingletons(userService) //register an operations source and use the default strategy
      .withNestedResolverBuildersForType(User.class, new BeanResolverBuilder()) //customize how queries are extracted from User.class
      .generate();
 GraphQL graphQL = new GraphQL(schema);

 //keep the reference to GraphQL instance and execute queries against it.
 //this query selects a user by ID and requests name and regDate fields only
 ExecutionResult result = graphQL.execute(
 "{ user (id: 123) {
      name,
      regDate
  }}");
  
 
  • Field Details

    • interfaceStrategy

      protected io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy interfaceStrategy
    • scalarStrategy

      protected io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy scalarStrategy
    • abstractInputHandler

      protected io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler abstractInputHandler
    • operationBuilder

      protected io.leangen.graphql.metadata.strategy.query.OperationBuilder operationBuilder
    • directiveBuilder

      protected io.leangen.graphql.metadata.strategy.query.DirectiveBuilder directiveBuilder
    • valueMapperFactory

      protected io.leangen.graphql.metadata.strategy.value.ValueMapperFactory valueMapperFactory
    • inclusionStrategy

      protected io.leangen.graphql.metadata.strategy.InclusionStrategy inclusionStrategy
    • implDiscoveryStrategy

      protected io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy implDiscoveryStrategy
    • typeInfoGenerator

      protected io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator typeInfoGenerator
    • typeTransformer

      protected io.leangen.graphql.metadata.strategy.type.TypeTransformer typeTransformer
    • environment

      protected io.leangen.graphql.execution.GlobalEnvironment environment
    • basePackages

      protected String[] basePackages
    • messageBundle

      protected io.leangen.graphql.metadata.messages.DelegatingMessageBundle messageBundle
    • typeMappers

      protected List<io.leangen.graphql.generator.mapping.TypeMapper> typeMappers
    • transformers

      protected List<io.leangen.graphql.generator.mapping.SchemaTransformer> transformers
    • typeComparator

      protected Comparator<AnnotatedType> typeComparator
    • inputFieldBuilders

      protected List<io.leangen.graphql.metadata.strategy.value.InputFieldBuilder> inputFieldBuilders
    • interceptorFactory

      protected io.leangen.graphql.execution.ResolverInterceptorFactory interceptorFactory
    • javaDeprecationConfig

      protected io.leangen.graphql.generator.JavaDeprecationMappingConfig javaDeprecationConfig
    • operationSourceRegistry

      protected final io.leangen.graphql.generator.OperationSourceRegistry operationSourceRegistry
    • typeMapperProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.TypeMapper>> typeMapperProviders
    • schemaTransformerProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.SchemaTransformer>> schemaTransformerProviders
    • inputConverterProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.InputConverter>> inputConverterProviders
    • outputConverterProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.OutputConverter>> outputConverterProviders
    • argumentInjectorProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.ArgumentInjector>> argumentInjectorProviders
    • inputFieldBuilderProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.ExtendedGeneratorConfiguration,io.leangen.graphql.metadata.strategy.value.InputFieldBuilder>> inputFieldBuilderProviders
    • resolverBuilderProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> resolverBuilderProviders
    • nestedResolverBuilderProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> nestedResolverBuilderProviders
    • moduleProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.module.Module>> moduleProviders
    • interceptorFactoryProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.execution.ResolverInterceptorFactory>> interceptorFactoryProviders
    • typeComparatorProviders

      protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,Comparator<AnnotatedType>>> typeComparatorProviders
    • processors

      protected final Collection<io.leangen.graphql.GraphQLSchemaProcessor> processors
    • relayMappingConfig

      protected final io.leangen.graphql.generator.RelayMappingConfig relayMappingConfig
    • additionalDirectives

      protected final Map<String,graphql.schema.GraphQLDirective> additionalDirectives
    • additionalDirectiveTypes

      protected final List<AnnotatedType> additionalDirectiveTypes
    • codeRegistry

      protected final graphql.schema.GraphQLCodeRegistry.Builder codeRegistry
    • additionalTypes

      protected final Map<String,graphql.schema.GraphQLNamedType> additionalTypes
    • queryRoot

      protected final String queryRoot
    • mutationRoot

      protected final String mutationRoot
    • subscriptionRoot

      protected final String subscriptionRoot
    • queryRootDescription

      protected final String queryRootDescription
    • mutationRootDescription

      protected final String mutationRootDescription
    • subscriptionRootDescription

      protected final String subscriptionRootDescription
  • Constructor Details

    • BaseSpqrSchemaGenerator

      public BaseSpqrSchemaGenerator()
      Default constructor
    • BaseSpqrSchemaGenerator

      public BaseSpqrSchemaGenerator(String queryRoot, String mutationRoot, String subscriptionRoot)
      Constructor which allows to customize names of root types.
      Parameters:
      queryRoot - name of query root type
      mutationRoot - name of mutation root type
      subscriptionRoot - name of subscription root type
    • BaseSpqrSchemaGenerator

      public BaseSpqrSchemaGenerator(String queryRoot, String queryRootDescription, String mutationRoot, String mutationRootDescription, String subscriptionRoot, String subscriptionRootDescription)
      Constructor which allows to customize names of root types.
      Parameters:
      queryRoot - name of query root type
      queryRootDescription - query root description
      mutationRoot - name of mutation root type
      mutationRootDescription - mutation root description
      subscriptionRoot - name of subscription root type
      subscriptionRootDescription - subscription root description
  • Method Details

    • withOperationsFromSingleton

      public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Register serviceSingleton as a singleton OperationSource, with its class (obtained via Object.getClass()) as its runtime type, using the provided ResolverBuilders to look for methods to be exposed or the globally registered ResolverBuilders if none are provided. All query/mutation methods discovered by analyzing the serviceSingleton's type will be later, in query resolution time, invoked on this specific instance (hence the 'singleton' in the method name). Instances of stateless service classes are commonly registered this way. implNote: Injection containers (like Spring or CDI) will often wrap managed bean instances into proxies, making it difficult to reliably detect their type. For this reason, it is recommended in such cases to use a different overload of this method and provide the type explicitly.
      Overrides:
      withOperationsFromSingleton in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSingleton - The singleton bean whose type is to be scanned for query/mutation methods and on which those methods will be invoked in query/mutation execution time
      builders - Custom strategy to use when analyzing beanType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromSingleton

      public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Register serviceSingleton as a singleton OperationSource, with beanType as its static type, using the provided ResolverBuilders to look for methods to be exposed or the globally registered ResolverBuilders if none are provided. All query/mutation methods discovered by analyzing the beanType will be later, in query resolution time, invoked on this specific instance (hence the 'singleton' in the method name). Instances of stateless service classes are commonly registered this way.
      Overrides:
      withOperationsFromSingleton in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSingleton - The singleton bean whose type is to be scanned for query/mutation methods and on which those methods will be invoked in query/mutation execution time
      beanType - Runtime type of serviceSingleton. Should be explicitly provided when it differs from its class (that can be obtained via Object.getClass()). This is commonly the case when the class is generic or when the instance has been proxied by a framework. Use TypeToken to get a Type literal or TypeFactory to create it dynamically.
      builders - Custom strategy to use when analyzing beanType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromSingleton

      public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, AnnotatedType beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Same as withOperationsFromSingleton(Object, Type, ResolverBuilder...), except that an AnnotatedType is used as serviceSingleton's static type. Needed when type annotations such as GraphQLNonNull not directly declared on the class should be captured.
      Overrides:
      withOperationsFromSingleton in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSingleton - The singleton bean whose type is to be scanned for query/mutation methods and on which those methods will be invoked in query/mutation execution time
      beanType - Runtime type of serviceSingleton. Should be explicitly provided when it differs from its class (that can be obtained via Object.getClass()) and when annotations on the type should be kept. Use TypeToken to get an AnnotatedType literal or TypeFactory to create it dynamically.
      builders - Custom builders to use when analyzing beanType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromSingletons

      public BaseSpqrSchemaGenerator withOperationsFromSingletons(Object... serviceSingletons)
      Same as withOperationsFromSingleton(Object, ResolverBuilder...) except that multiple beans can be registered at the same time.
      Overrides:
      withOperationsFromSingletons in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSingletons - Singleton beans whose type is to be scanned for query/mutation methods and on which those methods will be invoked in query/mutation execution time
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromBean

      public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Analyzes beanType using the provided ResolverBuilders to look for methods to be exposed or the globally registered ResolverBuilders if none are provided, and uses serviceSupplier to obtain an instance on which query/mutation methods are invoked at runtime. Container managed beans (of any scope) are commonly registered this way..
      Overrides:
      withOperationsFromBean in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSupplier - The supplier that will be used to obtain an instance on which the exposed methods will be invoked when resolving queries/mutations/subscriptions.
      beanType - Static type of instances provided by serviceSupplier. Use TypeToken to get a Type literal or TypeFactory to create it dynamically.
      builders - Custom strategy to use when analyzing beanType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromBean

      public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, AnnotatedType beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Same as withOperationsFromBean(Supplier, Type, ResolverBuilder...), except that an AnnotatedType is used as the static type of the instances provided by serviceSupplier. Needed when type annotations such as GraphQLNonNull not directly declared on the class should be captured.
      Overrides:
      withOperationsFromBean in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOperationsFromBean

      public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, Type beanType, Class<?> exposedType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Same as withOperationsFromBean(Supplier, Type, ResolverBuilder...), but the actual runtime type of the instances provided by serviceSupplier will be used to choose the method to invoke at runtime. This is the absolute safest approach to registering beans, and is needed when the instances are proxied by a container (e.g. Spring, CDI or others) and can _not_ be cast to beanType at runtime.
      Overrides:
      withOperationsFromBean in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceSupplier - The supplier that will be used to obtain an instance on which the exposed methods will be invoked when resolving queries/mutations/subscriptions.
      beanType - Static type of instances provided by serviceSupplier. Use TypeToken to get a Type literal or TypeFactory to create it dynamically.
      exposedType - Runtime type of the instances provided by serviceSupplier, not necessarily possible to cast to beanType
      builders - Custom strategy to use when analyzing beanType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromBean

      public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, AnnotatedType beanType, Class<?> exposedType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Same as withOperationsFromBean(Supplier, Type, Class, ResolverBuilder...), except that an AnnotatedType is used as the static type of the instances provided by serviceSupplier. Needed when type annotations such as GraphQLNonNull not directly declared on the class should be captured.
      Overrides:
      withOperationsFromBean in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOperationsFromType

      public BaseSpqrSchemaGenerator withOperationsFromType(Type serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Analyzes serviceType using the provided ResolverBuilders to look for methods to be exposed or the globally registered ResolverBuilders if none are provided. An instance of serviceType on which the exposed methods are invoked at runtime must be explicitly provided as GraphQL root for each execution. See ExecutionInput.Builder.root(Object).
      Overrides:
      withOperationsFromType in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      serviceType - Type to analyze for methods to expose. Use TypeToken to get a Type literal or TypeFactory to create it dynamically.
      builders - Custom strategy to use when analyzing serviceType
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOperationsFromTypes

      public BaseSpqrSchemaGenerator withOperationsFromTypes(Type... serviceType)
      Overrides:
      withOperationsFromTypes in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOperationsFromType

      public BaseSpqrSchemaGenerator withOperationsFromType(AnnotatedType serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders)
      Same as withOperationsFromType(Type, ResolverBuilder...), except that an AnnotatedType is used. Needed when type annotations such as GraphQLNonNull not directly declared on the class should be captured.
      Overrides:
      withOperationsFromType in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOperationsFromTypes

      public BaseSpqrSchemaGenerator withOperationsFromTypes(AnnotatedType... serviceType)
      Overrides:
      withOperationsFromTypes in class io.leangen.graphql.GraphQLSchemaGenerator
    • withResolverBuilders

      public BaseSpqrSchemaGenerator withResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders)
      Globally registers ResolverBuilders to be used for sources that don't have explicitly assigned builders.
      Overrides:
      withResolverBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      resolverBuilders - builders to be globally registered
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withResolverBuilders

      public BaseSpqrSchemaGenerator withResolverBuilders(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder> provider)
      Overrides:
      withResolverBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
    • withNestedResolverBuilders

      public BaseSpqrSchemaGenerator withNestedResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders)
      Globally registers ResolverBuilders to be used for sources that don't have explicitly assigned builders.
      Overrides:
      withNestedResolverBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      resolverBuilders - builders to be globally registered
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withNestedResolverBuilders

      public BaseSpqrSchemaGenerator withNestedResolverBuilders(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder> provider)
      Overrides:
      withNestedResolverBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInputFieldBuilders

      public BaseSpqrSchemaGenerator withInputFieldBuilders(io.leangen.graphql.metadata.strategy.value.InputFieldBuilder... inputFieldBuilders)
      Overrides:
      withInputFieldBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInputFieldBuilders

      public BaseSpqrSchemaGenerator withInputFieldBuilders(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.ExtendedGeneratorConfiguration,io.leangen.graphql.metadata.strategy.value.InputFieldBuilder> provider)
      Overrides:
      withInputFieldBuilders in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAbstractInputTypeResolution

      public BaseSpqrSchemaGenerator withAbstractInputTypeResolution()
      Overrides:
      withAbstractInputTypeResolution in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAbstractInputHandler

      public BaseSpqrSchemaGenerator withAbstractInputHandler(io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler abstractInputHandler)
      Overrides:
      withAbstractInputHandler in class io.leangen.graphql.GraphQLSchemaGenerator
    • withBasePackages

      public BaseSpqrSchemaGenerator withBasePackages(String... basePackages)
      Overrides:
      withBasePackages in class io.leangen.graphql.GraphQLSchemaGenerator
    • withStringInterpolation

      public BaseSpqrSchemaGenerator withStringInterpolation(io.leangen.graphql.metadata.messages.MessageBundle... messageBundles)
      Overrides:
      withStringInterpolation in class io.leangen.graphql.GraphQLSchemaGenerator
    • withJavaDeprecationRespected

      public BaseSpqrSchemaGenerator withJavaDeprecationRespected(boolean respectJavaDeprecation)
      Overrides:
      withJavaDeprecationRespected in class io.leangen.graphql.GraphQLSchemaGenerator
    • withJavaDeprecationReason

      public BaseSpqrSchemaGenerator withJavaDeprecationReason(String deprecationReason)
      Overrides:
      withJavaDeprecationReason in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeInfoGenerator

      public BaseSpqrSchemaGenerator withTypeInfoGenerator(io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator typeInfoGenerator)
      Overrides:
      withTypeInfoGenerator in class io.leangen.graphql.GraphQLSchemaGenerator
    • withValueMapperFactory

      public BaseSpqrSchemaGenerator withValueMapperFactory(io.leangen.graphql.metadata.strategy.value.ValueMapperFactory valueMapperFactory)
      Overrides:
      withValueMapperFactory in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInterfaceMappingStrategy

      public BaseSpqrSchemaGenerator withInterfaceMappingStrategy(io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy interfaceStrategy)
      Overrides:
      withInterfaceMappingStrategy in class io.leangen.graphql.GraphQLSchemaGenerator
    • withScalarDeserializationStrategy

      public BaseSpqrSchemaGenerator withScalarDeserializationStrategy(io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy scalarStrategy)
      Overrides:
      withScalarDeserializationStrategy in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInclusionStrategy

      public BaseSpqrSchemaGenerator withInclusionStrategy(io.leangen.graphql.metadata.strategy.InclusionStrategy inclusionStrategy)
      Overrides:
      withInclusionStrategy in class io.leangen.graphql.GraphQLSchemaGenerator
    • withImplementationDiscoveryStrategy

      public BaseSpqrSchemaGenerator withImplementationDiscoveryStrategy(io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy implDiscoveryStrategy)
      Overrides:
      withImplementationDiscoveryStrategy in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeTransformer

      public BaseSpqrSchemaGenerator withTypeTransformer(io.leangen.graphql.metadata.strategy.type.TypeTransformer transformer)
      Overrides:
      withTypeTransformer in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeMappers

      public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers)
      Registers custom TypeMappers to be used for mapping Java type to GraphQL types.

      Ordering of mappers is strictly important as the first TypeMapper that supports the given Java type will be used for mapping it.

      See TypeMapper.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)

      Overrides:
      withTypeMappers in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      typeMappers - Custom type mappers to register with the builder
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withTypeMappersPrepended

      public BaseSpqrSchemaGenerator withTypeMappersPrepended(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers)
      Overrides:
      withTypeMappersPrepended in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeMappersPrepended

      public BaseSpqrSchemaGenerator withTypeMappersPrepended(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.TypeMapper> provider)
      Overrides:
      withTypeMappersPrepended in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeMappers

      public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.TypeMapper> provider)
      Registers custom TypeMappers to be used for mapping Java type to GraphQL types.

      Ordering of mappers is strictly important as the first TypeMapper that supports the given Java type will be used for mapping it.

      See TypeMapper.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)

      Overrides:
      withTypeMappers in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      provider - Provides the customized list of TypeMappers to use
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withSchemaTransformers

      public BaseSpqrSchemaGenerator withSchemaTransformers(io.leangen.graphql.generator.mapping.SchemaTransformer... transformers)
      Overrides:
      withSchemaTransformers in class io.leangen.graphql.GraphQLSchemaGenerator
    • withSchemaTransformers

      public BaseSpqrSchemaGenerator withSchemaTransformers(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.SchemaTransformer> provider)
      Overrides:
      withSchemaTransformers in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInputConverters

      public BaseSpqrSchemaGenerator withInputConverters(io.leangen.graphql.generator.mapping.InputConverter<?,?>... inputConverters)
      Registers custom InputConverters to be used for converting values provided by the GraphQL client into those expected by the corresponding Java method. Only needed in some specific cases when usual deserialization isn't enough, for example, when a client-provided List should be repackaged into a Map, which is normally done because GraphQL type system has no direct support for maps.

      Ordering of converters is strictly important as the first InputConverter that supports the given Java type will be used for converting it.

      See InputConverter.supports(AnnotatedType)

      Overrides:
      withInputConverters in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      inputConverters - Custom input converters to register with the builder
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withInputConvertersPrepended

      public BaseSpqrSchemaGenerator withInputConvertersPrepended(io.leangen.graphql.generator.mapping.InputConverter<?,?>... inputConverters)
      Overrides:
      withInputConvertersPrepended in class io.leangen.graphql.GraphQLSchemaGenerator
    • withInputConverters

      public BaseSpqrSchemaGenerator withInputConverters(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.InputConverter> provider)
      Overrides:
      withInputConverters in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOutputConverters

      public BaseSpqrSchemaGenerator withOutputConverters(io.leangen.graphql.generator.mapping.OutputConverter<?,?>... outputConverters)
      Registers custom OutputConverters to be used for converting values returned by the exposed Java method into those expected by the GraphQL client. Only needed in some specific cases when usual serialization isn't enough, for example, when an instance of Map should be repackaged into a List, which is normally done because GraphQL type system has no direct support for maps.

      Ordering of converters is strictly important as the first OutputConverter that supports the given Java type will be used for converting it.

      See OutputConverter.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)

      Overrides:
      withOutputConverters in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      outputConverters - Custom output converters to register with the builder
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withOutputConvertersPrepended

      public BaseSpqrSchemaGenerator withOutputConvertersPrepended(io.leangen.graphql.generator.mapping.OutputConverter<?,?>... outputConverters)
      Overrides:
      withOutputConvertersPrepended in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOutputConverters

      public BaseSpqrSchemaGenerator withOutputConverters(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.OutputConverter> provider)
      Overrides:
      withOutputConverters in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeAdapters

      public BaseSpqrSchemaGenerator withTypeAdapters(io.leangen.graphql.generator.mapping.AbstractTypeAdapter<?,?>... typeAdapters)
      Type adapters (instances of AbstractTypeAdapter) are both type mappers and bi-directional converters, implementing TypeMapper, InputConverter and OutputConverter. They're used in the same way as mappers/converters individually, and exist solely because it can sometimes be convenient to group the logic for mapping and converting to/from the same Java type in one place. For example, because GraphQL type system has no notion of maps, Maps require special logic both when mapping them to a GraphQL type and when converting them before and after invoking a Java method. For this reason, all code dealing with translating Maps is kept in one place in MapToListTypeAdapter.

      Ordering of mappers/converters is strictly important as the first one supporting the given Java type will be used to map/convert it.

      See withTypeMappers(ExtensionProvider)

      See withInputConverters(ExtensionProvider)

      See withOutputConverters(ExtensionProvider)

      Overrides:
      withTypeAdapters in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      typeAdapters - Custom type adapters to register with the builder
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withArgumentInjectors

      public BaseSpqrSchemaGenerator withArgumentInjectors(io.leangen.graphql.generator.mapping.ArgumentInjector... argumentInjectors)
      Overrides:
      withArgumentInjectors in class io.leangen.graphql.GraphQLSchemaGenerator
    • withArgumentInjectors

      public BaseSpqrSchemaGenerator withArgumentInjectors(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.ArgumentInjector> provider)
      Overrides:
      withArgumentInjectors in class io.leangen.graphql.GraphQLSchemaGenerator
    • withModules

      public BaseSpqrSchemaGenerator withModules(io.leangen.graphql.module.Module... modules)
      Overrides:
      withModules in class io.leangen.graphql.GraphQLSchemaGenerator
    • withModules

      public BaseSpqrSchemaGenerator withModules(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.module.Module> provider)
      Overrides:
      withModules in class io.leangen.graphql.GraphQLSchemaGenerator
    • withResolverInterceptors

      public BaseSpqrSchemaGenerator withResolverInterceptors(io.leangen.graphql.execution.ResolverInterceptor... interceptors)
      Overrides:
      withResolverInterceptors in class io.leangen.graphql.GraphQLSchemaGenerator
    • withResolverInterceptorFactories

      public BaseSpqrSchemaGenerator withResolverInterceptorFactories(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.execution.ResolverInterceptorFactory> provider)
      Overrides:
      withResolverInterceptorFactories in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAdditionalTypes

      @Deprecated public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<graphql.schema.GraphQLType> additionalTypes)
      Deprecated.
      Overrides:
      withAdditionalTypes in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAdditionalTypes

      public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<? extends graphql.schema.GraphQLType> additionalTypes, graphql.schema.GraphQLCodeRegistry codeRegistry)
      Overrides:
      withAdditionalTypes in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAdditionalTypes

      public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<? extends graphql.schema.GraphQLType> additionalTypes, BaseSpqrSchemaGenerator.CodeRegistryBuilder codeRegistryUpdater)
    • merge

      protected void merge(graphql.schema.GraphQLType type, Map<String,graphql.schema.GraphQLNamedType> additionalTypes, BaseSpqrSchemaGenerator.CodeRegistryBuilder updater, graphql.schema.GraphQLCodeRegistry.Builder builder)
    • withAdditionalDirectives

      public BaseSpqrSchemaGenerator withAdditionalDirectives(Type... additionalDirectives)
      Overrides:
      withAdditionalDirectives in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAdditionalDirectives

      public BaseSpqrSchemaGenerator withAdditionalDirectives(AnnotatedType... additionalDirectives)
      Overrides:
      withAdditionalDirectives in class io.leangen.graphql.GraphQLSchemaGenerator
    • withAdditionalDirectives

      public BaseSpqrSchemaGenerator withAdditionalDirectives(graphql.schema.GraphQLDirective... additionalDirectives)
      Overrides:
      withAdditionalDirectives in class io.leangen.graphql.GraphQLSchemaGenerator
    • withTypeComparators

      public BaseSpqrSchemaGenerator withTypeComparators(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,Comparator<AnnotatedType>> provider)
      Overrides:
      withTypeComparators in class io.leangen.graphql.GraphQLSchemaGenerator
    • withOperationBuilder

      public BaseSpqrSchemaGenerator withOperationBuilder(io.leangen.graphql.metadata.strategy.query.OperationBuilder operationBuilder)
      Overrides:
      withOperationBuilder in class io.leangen.graphql.GraphQLSchemaGenerator
    • withDirectiveBuilder

      public BaseSpqrSchemaGenerator withDirectiveBuilder(io.leangen.graphql.metadata.strategy.query.DirectiveBuilder directiveBuilder)
      Overrides:
      withDirectiveBuilder in class io.leangen.graphql.GraphQLSchemaGenerator
    • withRelayCompliantMutations

      public BaseSpqrSchemaGenerator withRelayCompliantMutations()
      Sets a flag that all mutations should be mapped in a Relay-compliant way, using the default name and description for output wrapper fields.
      Overrides:
      withRelayCompliantMutations in class io.leangen.graphql.GraphQLSchemaGenerator
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withRelayCompliantMutations

      public BaseSpqrSchemaGenerator withRelayCompliantMutations(String wrapperFieldName, String wrapperFieldDescription)
      Sets a flag signifying that all mutations should be mapped in a Relay-compliant way, using the default name and description for output wrapper fields.
      Overrides:
      withRelayCompliantMutations in class io.leangen.graphql.GraphQLSchemaGenerator
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withRelayNodeInterfaceInference

      public BaseSpqrSchemaGenerator withRelayNodeInterfaceInference(boolean enabled)
      Sets the flag controlling whether the Node interface (as defined by the Relay spec) should be automatically inferred for types that have an ID field.
      Overrides:
      withRelayNodeInterfaceInference in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      enabled - Whether the inference should be enabled
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withRelayConnectionCheckRelaxed

      public BaseSpqrSchemaGenerator withRelayConnectionCheckRelaxed()
      Removes the requirement on queries returning a Connection to comply with the Relay Connection spec
      Overrides:
      withRelayConnectionCheckRelaxed in class io.leangen.graphql.GraphQLSchemaGenerator
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • withSchemaProcessors

      public BaseSpqrSchemaGenerator withSchemaProcessors(io.leangen.graphql.GraphQLSchemaProcessor... processors)
      Registers custom schema processors that can perform arbitrary transformations on the schema just before it is built.
      Overrides:
      withSchemaProcessors in class io.leangen.graphql.GraphQLSchemaGenerator
      Parameters:
      processors - Custom processors to call right before the GraphQL schema is built
      Returns:
      This BaseSpqrSchemaGenerator instance, to allow method chaining
    • init

      protected void init()
      Sets the default values for all settings not configured explicitly, ensuring the builder is in a valid state
    • generate

      public graphql.schema.GraphQLSchema generate()
      Generates a GraphQL schema based on the results of analysis of the registered sources. All exposed methods will be mapped as queries or mutations and all Java types referred to by those methods will be mapped to corresponding GraphQL types. Such schema can then be used to construct GraphQL instances. See the example in the description of this class.
      Overrides:
      generate in class io.leangen.graphql.GraphQLSchemaGenerator
      Returns:
      A GraphQL schema
    • applyProcessors

      protected void applyProcessors(graphql.schema.GraphQLSchema.Builder builder, io.leangen.graphql.generator.BuildContext buildContext)
    • isRealType

      protected boolean isRealType(graphql.schema.GraphQLNamedType type)
    • checkType

      protected Type checkType(Type type)
    • checkType

      protected void checkType(AnnotatedType type)
    • checkForEmptyOrDuplicates

      protected void checkForEmptyOrDuplicates(String extensionType, List<?> extensions)
    • checkForDuplicates

      protected <E> void checkForDuplicates(String extensionType, List<E> extensions)