Class BaseSpqrSchemaGenerator
- Direct Known Subclasses:
SpqrSchemaGenerator
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 TypeMapper
s 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
}}");
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
protected static class
protected static class
protected static class
protected static class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler
protected final List<AnnotatedType>
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.generator.mapping.ArgumentInjector>> protected String[]
protected final graphql.schema.GraphQLCodeRegistry.Builder
protected io.leangen.graphql.metadata.strategy.query.DirectiveBuilder
protected io.leangen.graphql.execution.GlobalEnvironment
protected io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy
protected io.leangen.graphql.metadata.strategy.InclusionStrategy
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.generator.mapping.InputConverter>> protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.ExtendedGeneratorConfiguration,
io.leangen.graphql.metadata.strategy.value.InputFieldBuilder>> protected List<io.leangen.graphql.metadata.strategy.value.InputFieldBuilder>
protected io.leangen.graphql.execution.ResolverInterceptorFactory
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.execution.ResolverInterceptorFactory>> protected io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy
protected io.leangen.graphql.generator.JavaDeprecationMappingConfig
protected io.leangen.graphql.metadata.messages.DelegatingMessageBundle
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.module.Module>> protected final String
protected final String
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> protected io.leangen.graphql.metadata.strategy.query.OperationBuilder
protected final io.leangen.graphql.generator.OperationSourceRegistry
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.generator.mapping.OutputConverter>> protected final Collection<io.leangen.graphql.GraphQLSchemaProcessor>
protected final String
protected final String
protected final io.leangen.graphql.generator.RelayMappingConfig
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> protected io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.generator.mapping.SchemaTransformer>> protected final String
protected final String
protected List<io.leangen.graphql.generator.mapping.SchemaTransformer>
protected Comparator<AnnotatedType>
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
Comparator<AnnotatedType>>> protected io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator
protected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,
io.leangen.graphql.generator.mapping.TypeMapper>> protected List<io.leangen.graphql.generator.mapping.TypeMapper>
protected io.leangen.graphql.metadata.strategy.type.TypeTransformer
protected io.leangen.graphql.metadata.strategy.value.ValueMapperFactory
-
Constructor Summary
ConstructorDescriptionDefault constructorBaseSpqrSchemaGenerator
(String queryRoot, String mutationRoot, String subscriptionRoot) Constructor which allows to customize names of root types.BaseSpqrSchemaGenerator
(String queryRoot, String queryRootDescription, String mutationRoot, String mutationRootDescription, String subscriptionRoot, String subscriptionRootDescription) Constructor which allows to customize names of root types. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyProcessors
(graphql.schema.GraphQLSchema.Builder builder, io.leangen.graphql.generator.BuildContext buildContext) protected <E> void
checkForDuplicates
(String extensionType, List<E> extensions) protected void
checkForEmptyOrDuplicates
(String extensionType, List<?> extensions) protected void
checkType
(AnnotatedType type) protected Type
graphql.schema.GraphQLSchema
generate()
Generates a GraphQL schema based on the results of analysis of the registered sources.protected void
init()
Sets the default values for all settings not configured explicitly, ensuring the builder is in a valid stateprotected boolean
isRealType
(graphql.schema.GraphQLNamedType type) protected void
merge
(graphql.schema.GraphQLType type, Map<String, graphql.schema.GraphQLNamedType> additionalTypes, BaseSpqrSchemaGenerator.CodeRegistryBuilder updater, graphql.schema.GraphQLCodeRegistry.Builder builder) withAbstractInputHandler
(io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler abstractInputHandler) withAdditionalDirectives
(graphql.schema.GraphQLDirective... additionalDirectives) withAdditionalDirectives
(AnnotatedType... additionalDirectives) withAdditionalDirectives
(Type... additionalDirectives) withAdditionalTypes
(Collection<? extends graphql.schema.GraphQLType> additionalTypes, graphql.schema.GraphQLCodeRegistry codeRegistry) withAdditionalTypes
(Collection<? extends graphql.schema.GraphQLType> additionalTypes, BaseSpqrSchemaGenerator.CodeRegistryBuilder codeRegistryUpdater) withAdditionalTypes
(Collection<graphql.schema.GraphQLType> additionalTypes) Deprecated.withArgumentInjectors
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.ArgumentInjector> provider) withArgumentInjectors
(io.leangen.graphql.generator.mapping.ArgumentInjector... argumentInjectors) withBasePackages
(String... basePackages) withDirectiveBuilder
(io.leangen.graphql.metadata.strategy.query.DirectiveBuilder directiveBuilder) withImplementationDiscoveryStrategy
(io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy implDiscoveryStrategy) withInclusionStrategy
(io.leangen.graphql.metadata.strategy.InclusionStrategy inclusionStrategy) withInputConverters
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.InputConverter> provider) withInputConverters
(io.leangen.graphql.generator.mapping.InputConverter<?, ?>... inputConverters) Registers customInputConverter
s to be used for converting values provided by the GraphQL client into those expected by the corresponding Java method.withInputConvertersPrepended
(io.leangen.graphql.generator.mapping.InputConverter<?, ?>... inputConverters) withInputFieldBuilders
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.ExtendedGeneratorConfiguration, io.leangen.graphql.metadata.strategy.value.InputFieldBuilder> provider) withInputFieldBuilders
(io.leangen.graphql.metadata.strategy.value.InputFieldBuilder... inputFieldBuilders) withInterfaceMappingStrategy
(io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy interfaceStrategy) withJavaDeprecationReason
(String deprecationReason) withJavaDeprecationRespected
(boolean respectJavaDeprecation) withModules
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.module.Module> provider) withModules
(io.leangen.graphql.module.Module... modules) withNestedResolverBuilders
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.metadata.strategy.query.ResolverBuilder> provider) withNestedResolverBuilders
(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilder
s to be used for sources that don't have explicitly assigned builders.withOperationBuilder
(io.leangen.graphql.metadata.strategy.query.OperationBuilder operationBuilder) withOperationsFromBean
(Supplier<Object> serviceSupplier, AnnotatedType beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromBean(Supplier, Type, ResolverBuilder...)
, except that anAnnotatedType
is used as the static type of the instances provided byserviceSupplier
.withOperationsFromBean
(Supplier<Object> serviceSupplier, AnnotatedType beanType, Class<?> exposedType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromBean(Supplier, Type, Class, ResolverBuilder...)
, except that anAnnotatedType
is used as the static type of the instances provided byserviceSupplier
.withOperationsFromBean
(Supplier<Object> serviceSupplier, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesbeanType
using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided, and usesserviceSupplier
to obtain an instance on which query/mutation methods are invoked at runtime.withOperationsFromBean
(Supplier<Object> serviceSupplier, Type beanType, Class<?> exposedType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromBean(Supplier, Type, ResolverBuilder...)
, but the actual runtime type of the instances provided byserviceSupplier
will be used to choose the method to invoke at runtime.withOperationsFromSingleton
(Object serviceSingleton, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingleton
as a singletonOperationSource
, with its class (obtained viaObject.getClass()
) as its runtime type, using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided.withOperationsFromSingleton
(Object serviceSingleton, AnnotatedType beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromSingleton(Object, Type, ResolverBuilder...)
, except that anAnnotatedType
is used asserviceSingleton
's static type.withOperationsFromSingleton
(Object serviceSingleton, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingleton
as a singletonOperationSource
, withbeanType
as its static type, using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided.withOperationsFromSingletons
(Object... serviceSingletons) Same aswithOperationsFromSingleton(Object, ResolverBuilder...)
except that multiple beans can be registered at the same time.withOperationsFromType
(AnnotatedType serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromType(Type, ResolverBuilder...)
, except that anAnnotatedType
is used.withOperationsFromType
(Type serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesserviceType
using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided.withOperationsFromTypes
(AnnotatedType... serviceType) withOperationsFromTypes
(Type... serviceType) withOutputConverters
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.OutputConverter> provider) withOutputConverters
(io.leangen.graphql.generator.mapping.OutputConverter<?, ?>... outputConverters) Registers customOutputConverter
s to be used for converting values returned by the exposed Java method into those expected by the GraphQL client.withOutputConvertersPrepended
(io.leangen.graphql.generator.mapping.OutputConverter<?, ?>... outputConverters) Sets a flag that all mutations should be mapped in a Relay-compliant way, using the default name and description for output wrapper fields.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.Removes the requirement on queries returning a Connection to comply with the Relay Connection specwithRelayNodeInterfaceInference
(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.withResolverBuilders
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.metadata.strategy.query.ResolverBuilder> provider) withResolverBuilders
(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilder
s to be used for sources that don't have explicitly assigned builders.withResolverInterceptorFactories
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.execution.ResolverInterceptorFactory> provider) withResolverInterceptors
(io.leangen.graphql.execution.ResolverInterceptor... interceptors) withScalarDeserializationStrategy
(io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy scalarStrategy) withSchemaProcessors
(io.leangen.graphql.GraphQLSchemaProcessor... processors) Registers custom schema processors that can perform arbitrary transformations on the schema just before it is built.withSchemaTransformers
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.SchemaTransformer> provider) withSchemaTransformers
(io.leangen.graphql.generator.mapping.SchemaTransformer... transformers) withStringInterpolation
(io.leangen.graphql.metadata.messages.MessageBundle... messageBundles) withTypeAdapters
(io.leangen.graphql.generator.mapping.AbstractTypeAdapter<?, ?>... typeAdapters) Type adapters (instances ofAbstractTypeAdapter
) are both type mappers and bi-directional converters, implementingTypeMapper
,InputConverter
andOutputConverter
.withTypeComparators
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, Comparator<AnnotatedType>> provider) withTypeInfoGenerator
(io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator typeInfoGenerator) withTypeMappers
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.TypeMapper> provider) Registers customTypeMapper
s to be used for mapping Java type to GraphQL types.withTypeMappers
(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) Registers customTypeMapper
s to be used for mapping Java type to GraphQL types.withTypeMappersPrepended
(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.TypeMapper> provider) withTypeMappersPrepended
(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) withTypeTransformer
(io.leangen.graphql.metadata.strategy.type.TypeTransformer transformer) withValueMapperFactory
(io.leangen.graphql.metadata.strategy.value.ValueMapperFactory valueMapperFactory) Methods inherited from class io.leangen.graphql.GraphQLSchemaGenerator
withAdditionalTypes, withTypeComparators
-
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
-
messageBundle
protected io.leangen.graphql.metadata.messages.DelegatingMessageBundle messageBundle -
typeMappers
-
transformers
-
typeComparator
-
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
-
relayMappingConfig
protected final io.leangen.graphql.generator.RelayMappingConfig relayMappingConfig -
additionalDirectives
-
additionalDirectiveTypes
-
codeRegistry
protected final graphql.schema.GraphQLCodeRegistry.Builder codeRegistry -
additionalTypes
-
queryRoot
-
mutationRoot
-
subscriptionRoot
-
queryRootDescription
-
mutationRootDescription
-
subscriptionRootDescription
-
-
Constructor Details
-
BaseSpqrSchemaGenerator
public BaseSpqrSchemaGenerator()Default constructor -
BaseSpqrSchemaGenerator
Constructor which allows to customize names of root types.- Parameters:
queryRoot
- name of query root typemutationRoot
- name of mutation root typesubscriptionRoot
- 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 typequeryRootDescription
- query root descriptionmutationRoot
- name of mutation root typemutationRootDescription
- mutation root descriptionsubscriptionRoot
- name of subscription root typesubscriptionRootDescription
- subscription root description
-
-
Method Details
-
withOperationsFromSingleton
public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingleton
as a singletonOperationSource
, with its class (obtained viaObject.getClass()
) as its runtime type, using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided. All query/mutation methods discovered by analyzing theserviceSingleton
'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 classio.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 timebuilders
- Custom strategy to use when analyzingbeanType
- Returns:
- This
BaseSpqrSchemaGenerator
instance, to allow method chaining
-
withOperationsFromSingleton
public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingleton
as a singletonOperationSource
, withbeanType
as its static type, using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided. All query/mutation methods discovered by analyzing thebeanType
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 classio.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 timebeanType
- Runtime type ofserviceSingleton
. Should be explicitly provided when it differs from its class (that can be obtained viaObject.getClass()
). This is commonly the case when the class is generic or when the instance has been proxied by a framework. UseTypeToken
to get aType
literal orTypeFactory
to create it dynamically.builders
- Custom strategy to use when analyzingbeanType
- 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 aswithOperationsFromSingleton(Object, Type, ResolverBuilder...)
, except that anAnnotatedType
is used asserviceSingleton
's static type. Needed when type annotations such asGraphQLNonNull
not directly declared on the class should be captured.- Overrides:
withOperationsFromSingleton
in classio.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 timebeanType
- Runtime type ofserviceSingleton
. Should be explicitly provided when it differs from its class (that can be obtained viaObject.getClass()
) and when annotations on the type should be kept. UseTypeToken
to get anAnnotatedType
literal orTypeFactory
to create it dynamically.builders
- Custom builders to use when analyzingbeanType
- Returns:
- This
BaseSpqrSchemaGenerator
instance, to allow method chaining
-
withOperationsFromSingletons
Same aswithOperationsFromSingleton(Object, ResolverBuilder...)
except that multiple beans can be registered at the same time.- Overrides:
withOperationsFromSingletons
in classio.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) AnalyzesbeanType
using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided, and usesserviceSupplier
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 classio.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 byserviceSupplier
. UseTypeToken
to get aType
literal orTypeFactory
to create it dynamically.builders
- Custom strategy to use when analyzingbeanType
- 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 aswithOperationsFromBean(Supplier, Type, ResolverBuilder...)
, except that anAnnotatedType
is used as the static type of the instances provided byserviceSupplier
. Needed when type annotations such asGraphQLNonNull
not directly declared on the class should be captured.- Overrides:
withOperationsFromBean
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromBean
public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, Type beanType, Class<?> exposedType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromBean(Supplier, Type, ResolverBuilder...)
, but the actual runtime type of the instances provided byserviceSupplier
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 tobeanType
at runtime.- Overrides:
withOperationsFromBean
in classio.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 byserviceSupplier
. UseTypeToken
to get aType
literal orTypeFactory
to create it dynamically.exposedType
- Runtime type of the instances provided byserviceSupplier
, not necessarily possible to cast tobeanType
builders
- Custom strategy to use when analyzingbeanType
- 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 aswithOperationsFromBean(Supplier, Type, Class, ResolverBuilder...)
, except that anAnnotatedType
is used as the static type of the instances provided byserviceSupplier
. Needed when type annotations such asGraphQLNonNull
not directly declared on the class should be captured.- Overrides:
withOperationsFromBean
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromType
public BaseSpqrSchemaGenerator withOperationsFromType(Type serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesserviceType
using the providedResolverBuilder
s to look for methods to be exposed or the globally registeredResolverBuilder
s if none are provided. An instance ofserviceType
on which the exposed methods are invoked at runtime must be explicitly provided as GraphQLroot
for each execution. SeeExecutionInput.Builder.root(Object)
.- Overrides:
withOperationsFromType
in classio.leangen.graphql.GraphQLSchemaGenerator
- Parameters:
serviceType
- Type to analyze for methods to expose. UseTypeToken
to get aType
literal orTypeFactory
to create it dynamically.builders
- Custom strategy to use when analyzingserviceType
- Returns:
- This
BaseSpqrSchemaGenerator
instance, to allow method chaining
-
withOperationsFromTypes
- Overrides:
withOperationsFromTypes
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromType
public BaseSpqrSchemaGenerator withOperationsFromType(AnnotatedType serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromType(Type, ResolverBuilder...)
, except that anAnnotatedType
is used. Needed when type annotations such asGraphQLNonNull
not directly declared on the class should be captured.- Overrides:
withOperationsFromType
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromTypes
- Overrides:
withOperationsFromTypes
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverBuilders
public BaseSpqrSchemaGenerator withResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilder
s to be used for sources that don't have explicitly assigned builders.- Overrides:
withResolverBuilders
in classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withNestedResolverBuilders
public BaseSpqrSchemaGenerator withNestedResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilder
s to be used for sources that don't have explicitly assigned builders.- Overrides:
withNestedResolverBuilders
in classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withInputFieldBuilders
public BaseSpqrSchemaGenerator withInputFieldBuilders(io.leangen.graphql.metadata.strategy.value.InputFieldBuilder... inputFieldBuilders) - Overrides:
withInputFieldBuilders
in classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withAbstractInputTypeResolution
- Overrides:
withAbstractInputTypeResolution
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withAbstractInputHandler
public BaseSpqrSchemaGenerator withAbstractInputHandler(io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler abstractInputHandler) - Overrides:
withAbstractInputHandler
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withBasePackages
- Overrides:
withBasePackages
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withStringInterpolation
public BaseSpqrSchemaGenerator withStringInterpolation(io.leangen.graphql.metadata.messages.MessageBundle... messageBundles) - Overrides:
withStringInterpolation
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withJavaDeprecationRespected
- Overrides:
withJavaDeprecationRespected
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withJavaDeprecationReason
- Overrides:
withJavaDeprecationReason
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeInfoGenerator
public BaseSpqrSchemaGenerator withTypeInfoGenerator(io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator typeInfoGenerator) - Overrides:
withTypeInfoGenerator
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withValueMapperFactory
public BaseSpqrSchemaGenerator withValueMapperFactory(io.leangen.graphql.metadata.strategy.value.ValueMapperFactory valueMapperFactory) - Overrides:
withValueMapperFactory
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withInterfaceMappingStrategy
public BaseSpqrSchemaGenerator withInterfaceMappingStrategy(io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy interfaceStrategy) - Overrides:
withInterfaceMappingStrategy
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withScalarDeserializationStrategy
public BaseSpqrSchemaGenerator withScalarDeserializationStrategy(io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy scalarStrategy) - Overrides:
withScalarDeserializationStrategy
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withInclusionStrategy
public BaseSpqrSchemaGenerator withInclusionStrategy(io.leangen.graphql.metadata.strategy.InclusionStrategy inclusionStrategy) - Overrides:
withInclusionStrategy
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withImplementationDiscoveryStrategy
public BaseSpqrSchemaGenerator withImplementationDiscoveryStrategy(io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy implDiscoveryStrategy) - Overrides:
withImplementationDiscoveryStrategy
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeTransformer
public BaseSpqrSchemaGenerator withTypeTransformer(io.leangen.graphql.metadata.strategy.type.TypeTransformer transformer) - Overrides:
withTypeTransformer
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeMappers
public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) Registers customTypeMapper
s 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 classio.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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeMappers
public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.TypeMapper> provider) Registers customTypeMapper
s 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 classio.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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withInputConverters
public BaseSpqrSchemaGenerator withInputConverters(io.leangen.graphql.generator.mapping.InputConverter<?, ?>... inputConverters) Registers customInputConverter
s 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-providedList
should be repackaged into aMap
, 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 classio.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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withOutputConverters
public BaseSpqrSchemaGenerator withOutputConverters(io.leangen.graphql.generator.mapping.OutputConverter<?, ?>... outputConverters) Registers customOutputConverter
s 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 ofMap
should be repackaged into aList
, 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 classio.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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeAdapters
public BaseSpqrSchemaGenerator withTypeAdapters(io.leangen.graphql.generator.mapping.AbstractTypeAdapter<?, ?>... typeAdapters) Type adapters (instances ofAbstractTypeAdapter
) are both type mappers and bi-directional converters, implementingTypeMapper
,InputConverter
andOutputConverter
. 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,Map
s 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 translatingMap
s is kept in one place inMapToListTypeAdapter
.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)
- Overrides:
withTypeAdapters
in classio.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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
-
withModules
- Overrides:
withModules
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withModules
public BaseSpqrSchemaGenerator withModules(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.module.Module> provider) - Overrides:
withModules
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverInterceptors
public BaseSpqrSchemaGenerator withResolverInterceptors(io.leangen.graphql.execution.ResolverInterceptor... interceptors) - Overrides:
withResolverInterceptors
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverInterceptorFactories
public BaseSpqrSchemaGenerator withResolverInterceptorFactories(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.execution.ResolverInterceptorFactory> provider) - Overrides:
withResolverInterceptorFactories
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalTypes
@Deprecated public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<graphql.schema.GraphQLType> additionalTypes) Deprecated.- Overrides:
withAdditionalTypes
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalTypes
public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<? extends graphql.schema.GraphQLType> additionalTypes, graphql.schema.GraphQLCodeRegistry codeRegistry) - Overrides:
withAdditionalTypes
in classio.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
- Overrides:
withAdditionalDirectives
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalDirectives
- Overrides:
withAdditionalDirectives
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalDirectives
public BaseSpqrSchemaGenerator withAdditionalDirectives(graphql.schema.GraphQLDirective... additionalDirectives) - Overrides:
withAdditionalDirectives
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeComparators
public BaseSpqrSchemaGenerator withTypeComparators(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, Comparator<AnnotatedType>> provider) - Overrides:
withTypeComparators
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationBuilder
public BaseSpqrSchemaGenerator withOperationBuilder(io.leangen.graphql.metadata.strategy.query.OperationBuilder operationBuilder) - Overrides:
withOperationBuilder
in classio.leangen.graphql.GraphQLSchemaGenerator
-
withDirectiveBuilder
public BaseSpqrSchemaGenerator withDirectiveBuilder(io.leangen.graphql.metadata.strategy.query.DirectiveBuilder directiveBuilder) - Overrides:
withDirectiveBuilder
in classio.leangen.graphql.GraphQLSchemaGenerator
-
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 classio.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 classio.leangen.graphql.GraphQLSchemaGenerator
- Returns:
- This
BaseSpqrSchemaGenerator
instance, to allow method chaining
-
withRelayNodeInterfaceInference
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 classio.leangen.graphql.GraphQLSchemaGenerator
- Parameters:
enabled
- Whether the inference should be enabled- Returns:
- This
BaseSpqrSchemaGenerator
instance, to allow method chaining
-
withRelayConnectionCheckRelaxed
Removes the requirement on queries returning a Connection to comply with the Relay Connection spec- Overrides:
withRelayConnectionCheckRelaxed
in classio.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 classio.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 constructGraphQL
instances. See the example in the description of this class.- Overrides:
generate
in classio.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
-
checkType
-
checkForEmptyOrDuplicates
-
checkForDuplicates
-