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 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
}}");
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceprotected static classprotected static classprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.leangen.graphql.generator.mapping.strategy.AbstractInputHandlerprotected 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.Builderprotected io.leangen.graphql.metadata.strategy.query.DirectiveBuilderprotected io.leangen.graphql.execution.GlobalEnvironmentprotected io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategyprotected io.leangen.graphql.metadata.strategy.InclusionStrategyprotected 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.ResolverInterceptorFactoryprotected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.execution.ResolverInterceptorFactory>> protected io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategyprotected io.leangen.graphql.generator.JavaDeprecationMappingConfigprotected io.leangen.graphql.metadata.messages.DelegatingMessageBundleprotected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.module.Module>> protected final Stringprotected final Stringprotected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> protected io.leangen.graphql.metadata.strategy.query.OperationBuilderprotected final io.leangen.graphql.generator.OperationSourceRegistryprotected 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 Stringprotected final Stringprotected final io.leangen.graphql.generator.RelayMappingConfigprotected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.metadata.strategy.query.ResolverBuilder>> protected io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategyprotected final List<io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration,io.leangen.graphql.generator.mapping.SchemaTransformer>> protected final Stringprotected final Stringprotected 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.TypeInfoGeneratorprotected 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.TypeTransformerprotected io.leangen.graphql.metadata.strategy.value.ValueMapperFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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 voidapplyProcessors(graphql.schema.GraphQLSchema.Builder builder, io.leangen.graphql.generator.BuildContext buildContext) protected <E> voidcheckForDuplicates(String extensionType, List<E> extensions) protected voidcheckForEmptyOrDuplicates(String extensionType, List<?> extensions) protected voidcheckType(AnnotatedType type) protected Typegraphql.schema.GraphQLSchemagenerate()Generates a GraphQL schema based on the results of analysis of the registered sources.protected voidinit()Sets the default values for all settings not configured explicitly, ensuring the builder is in a valid stateprotected booleanisRealType(graphql.schema.GraphQLNamedType type) protected voidmerge(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 customInputConverters 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 registersResolverBuilders 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 anAnnotatedTypeis 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 anAnnotatedTypeis used as the static type of the instances provided byserviceSupplier.withOperationsFromBean(Supplier<Object> serviceSupplier, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesbeanTypeusing the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders if none are provided, and usesserviceSupplierto 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 byserviceSupplierwill be used to choose the method to invoke at runtime.withOperationsFromSingleton(Object serviceSingleton, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingletonas a singletonOperationSource, with its class (obtained viaObject.getClass()) as its runtime type, using the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders if none are provided.withOperationsFromSingleton(Object serviceSingleton, AnnotatedType beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromSingleton(Object, Type, ResolverBuilder...), except that anAnnotatedTypeis used asserviceSingleton's static type.withOperationsFromSingleton(Object serviceSingleton, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingletonas a singletonOperationSource, withbeanTypeas its static type, using the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders 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 anAnnotatedTypeis used.withOperationsFromType(Type serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesserviceTypeusing the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders 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 customOutputConverters 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 registersResolverBuilders 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,InputConverterandOutputConverter.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 customTypeMappers to be used for mapping Java type to GraphQL types.withTypeMappers(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) Registers customTypeMappers 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) RegisterserviceSingletonas a singletonOperationSource, with its class (obtained viaObject.getClass()) as its runtime type, using the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders 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:
withOperationsFromSingletonin 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
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withOperationsFromSingleton
public BaseSpqrSchemaGenerator withOperationsFromSingleton(Object serviceSingleton, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) RegisterserviceSingletonas a singletonOperationSource, withbeanTypeas its static type, using the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders if none are provided. All query/mutation methods discovered by analyzing thebeanTypewill 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:
withOperationsFromSingletonin 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. UseTypeTokento get aTypeliteral orTypeFactoryto create it dynamically.builders- Custom strategy to use when analyzingbeanType- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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 anAnnotatedTypeis used asserviceSingleton's static type. Needed when type annotations such asGraphQLNonNullnot directly declared on the class should be captured.- Overrides:
withOperationsFromSingletonin 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. UseTypeTokento get anAnnotatedTypeliteral orTypeFactoryto create it dynamically.builders- Custom builders to use when analyzingbeanType- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withOperationsFromSingletons
Same aswithOperationsFromSingleton(Object, ResolverBuilder...)except that multiple beans can be registered at the same time.- Overrides:
withOperationsFromSingletonsin 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
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withOperationsFromBean
public BaseSpqrSchemaGenerator withOperationsFromBean(Supplier<Object> serviceSupplier, Type beanType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesbeanTypeusing the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders if none are provided, and usesserviceSupplierto obtain an instance on which query/mutation methods are invoked at runtime. Container managed beans (of any scope) are commonly registered this way..- Overrides:
withOperationsFromBeanin 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. UseTypeTokento get aTypeliteral orTypeFactoryto create it dynamically.builders- Custom strategy to use when analyzingbeanType- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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 anAnnotatedTypeis used as the static type of the instances provided byserviceSupplier. Needed when type annotations such asGraphQLNonNullnot directly declared on the class should be captured.- Overrides:
withOperationsFromBeanin 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 byserviceSupplierwill 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 tobeanTypeat runtime.- Overrides:
withOperationsFromBeanin 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. UseTypeTokento get aTypeliteral orTypeFactoryto create it dynamically.exposedType- Runtime type of the instances provided byserviceSupplier, not necessarily possible to cast tobeanTypebuilders- Custom strategy to use when analyzingbeanType- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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 anAnnotatedTypeis used as the static type of the instances provided byserviceSupplier. Needed when type annotations such asGraphQLNonNullnot directly declared on the class should be captured.- Overrides:
withOperationsFromBeanin classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromType
public BaseSpqrSchemaGenerator withOperationsFromType(Type serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) AnalyzesserviceTypeusing the providedResolverBuilders to look for methods to be exposed or the globally registeredResolverBuilders if none are provided. An instance ofserviceTypeon which the exposed methods are invoked at runtime must be explicitly provided as GraphQLrootfor each execution. SeeExecutionInput.Builder.root(Object).- Overrides:
withOperationsFromTypein classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
serviceType- Type to analyze for methods to expose. UseTypeTokento get aTypeliteral orTypeFactoryto create it dynamically.builders- Custom strategy to use when analyzingserviceType- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withOperationsFromTypes
- Overrides:
withOperationsFromTypesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromType
public BaseSpqrSchemaGenerator withOperationsFromType(AnnotatedType serviceType, io.leangen.graphql.metadata.strategy.query.ResolverBuilder... builders) Same aswithOperationsFromType(Type, ResolverBuilder...), except that anAnnotatedTypeis used. Needed when type annotations such asGraphQLNonNullnot directly declared on the class should be captured.- Overrides:
withOperationsFromTypein classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationsFromTypes
- Overrides:
withOperationsFromTypesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverBuilders
public BaseSpqrSchemaGenerator withResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilders to be used for sources that don't have explicitly assigned builders.- Overrides:
withResolverBuildersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
resolverBuilders- builders to be globally registered- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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:
withResolverBuildersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withNestedResolverBuilders
public BaseSpqrSchemaGenerator withNestedResolverBuilders(io.leangen.graphql.metadata.strategy.query.ResolverBuilder... resolverBuilders) Globally registersResolverBuilders to be used for sources that don't have explicitly assigned builders.- Overrides:
withNestedResolverBuildersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
resolverBuilders- builders to be globally registered- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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:
withNestedResolverBuildersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withInputFieldBuilders
public BaseSpqrSchemaGenerator withInputFieldBuilders(io.leangen.graphql.metadata.strategy.value.InputFieldBuilder... inputFieldBuilders) - Overrides:
withInputFieldBuildersin 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:
withInputFieldBuildersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAbstractInputTypeResolution
- Overrides:
withAbstractInputTypeResolutionin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAbstractInputHandler
public BaseSpqrSchemaGenerator withAbstractInputHandler(io.leangen.graphql.generator.mapping.strategy.AbstractInputHandler abstractInputHandler) - Overrides:
withAbstractInputHandlerin classio.leangen.graphql.GraphQLSchemaGenerator
-
withBasePackages
- Overrides:
withBasePackagesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withStringInterpolation
public BaseSpqrSchemaGenerator withStringInterpolation(io.leangen.graphql.metadata.messages.MessageBundle... messageBundles) - Overrides:
withStringInterpolationin classio.leangen.graphql.GraphQLSchemaGenerator
-
withJavaDeprecationRespected
- Overrides:
withJavaDeprecationRespectedin classio.leangen.graphql.GraphQLSchemaGenerator
-
withJavaDeprecationReason
- Overrides:
withJavaDeprecationReasonin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeInfoGenerator
public BaseSpqrSchemaGenerator withTypeInfoGenerator(io.leangen.graphql.metadata.strategy.type.TypeInfoGenerator typeInfoGenerator) - Overrides:
withTypeInfoGeneratorin classio.leangen.graphql.GraphQLSchemaGenerator
-
withValueMapperFactory
public BaseSpqrSchemaGenerator withValueMapperFactory(io.leangen.graphql.metadata.strategy.value.ValueMapperFactory valueMapperFactory) - Overrides:
withValueMapperFactoryin classio.leangen.graphql.GraphQLSchemaGenerator
-
withInterfaceMappingStrategy
public BaseSpqrSchemaGenerator withInterfaceMappingStrategy(io.leangen.graphql.generator.mapping.strategy.InterfaceMappingStrategy interfaceStrategy) - Overrides:
withInterfaceMappingStrategyin classio.leangen.graphql.GraphQLSchemaGenerator
-
withScalarDeserializationStrategy
public BaseSpqrSchemaGenerator withScalarDeserializationStrategy(io.leangen.graphql.metadata.strategy.value.ScalarDeserializationStrategy scalarStrategy) - Overrides:
withScalarDeserializationStrategyin classio.leangen.graphql.GraphQLSchemaGenerator
-
withInclusionStrategy
public BaseSpqrSchemaGenerator withInclusionStrategy(io.leangen.graphql.metadata.strategy.InclusionStrategy inclusionStrategy) - Overrides:
withInclusionStrategyin classio.leangen.graphql.GraphQLSchemaGenerator
-
withImplementationDiscoveryStrategy
public BaseSpqrSchemaGenerator withImplementationDiscoveryStrategy(io.leangen.graphql.generator.mapping.strategy.ImplementationDiscoveryStrategy implDiscoveryStrategy) - Overrides:
withImplementationDiscoveryStrategyin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeTransformer
public BaseSpqrSchemaGenerator withTypeTransformer(io.leangen.graphql.metadata.strategy.type.TypeTransformer transformer) - Overrides:
withTypeTransformerin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeMappers
public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) Registers customTypeMappers to be used for mapping Java type to GraphQL types.Ordering of mappers is strictly important as the first
TypeMapperthat supports the given Java type will be used for mapping it.See
TypeMapper.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)- Overrides:
withTypeMappersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
typeMappers- Custom type mappers to register with the builder- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withTypeMappersPrepended
public BaseSpqrSchemaGenerator withTypeMappersPrepended(io.leangen.graphql.generator.mapping.TypeMapper... typeMappers) - Overrides:
withTypeMappersPrependedin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeMappersPrepended
public BaseSpqrSchemaGenerator withTypeMappersPrepended(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.TypeMapper> provider) - Overrides:
withTypeMappersPrependedin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeMappers
public BaseSpqrSchemaGenerator withTypeMappers(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.TypeMapper> provider) Registers customTypeMappers to be used for mapping Java type to GraphQL types.Ordering of mappers is strictly important as the first
TypeMapperthat supports the given Java type will be used for mapping it.See
TypeMapper.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)- Overrides:
withTypeMappersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
provider- Provides the customized list of TypeMappers to use- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withSchemaTransformers
public BaseSpqrSchemaGenerator withSchemaTransformers(io.leangen.graphql.generator.mapping.SchemaTransformer... transformers) - Overrides:
withSchemaTransformersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withSchemaTransformers
public BaseSpqrSchemaGenerator withSchemaTransformers(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.SchemaTransformer> provider) - Overrides:
withSchemaTransformersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withInputConverters
public BaseSpqrSchemaGenerator withInputConverters(io.leangen.graphql.generator.mapping.InputConverter<?, ?>... inputConverters) Registers customInputConverters 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-providedListshould 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
InputConverterthat supports the given Java type will be used for converting it.See
InputConverter.supports(AnnotatedType)- Overrides:
withInputConvertersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
inputConverters- Custom input converters to register with the builder- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withInputConvertersPrepended
public BaseSpqrSchemaGenerator withInputConvertersPrepended(io.leangen.graphql.generator.mapping.InputConverter<?, ?>... inputConverters) - Overrides:
withInputConvertersPrependedin classio.leangen.graphql.GraphQLSchemaGenerator
-
withInputConverters
public BaseSpqrSchemaGenerator withInputConverters(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.InputConverter> provider) - Overrides:
withInputConvertersin classio.leangen.graphql.GraphQLSchemaGenerator
-
withOutputConverters
public BaseSpqrSchemaGenerator withOutputConverters(io.leangen.graphql.generator.mapping.OutputConverter<?, ?>... outputConverters) Registers customOutputConverters 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 ofMapshould 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
OutputConverterthat supports the given Java type will be used for converting it.See
OutputConverter.supports(java.lang.reflect.AnnotatedElement, AnnotatedType)- Overrides:
withOutputConvertersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
outputConverters- Custom output converters to register with the builder- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withOutputConvertersPrepended
public BaseSpqrSchemaGenerator withOutputConvertersPrepended(io.leangen.graphql.generator.mapping.OutputConverter<?, ?>... outputConverters) - Overrides:
withOutputConvertersPrependedin classio.leangen.graphql.GraphQLSchemaGenerator
-
withOutputConverters
public BaseSpqrSchemaGenerator withOutputConverters(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.OutputConverter> provider) - Overrides:
withOutputConvertersin 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,InputConverterandOutputConverter. 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 translatingMaps 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:
withTypeAdaptersin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
typeAdapters- Custom type adapters to register with the builder- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withArgumentInjectors
public BaseSpqrSchemaGenerator withArgumentInjectors(io.leangen.graphql.generator.mapping.ArgumentInjector... argumentInjectors) - Overrides:
withArgumentInjectorsin classio.leangen.graphql.GraphQLSchemaGenerator
-
withArgumentInjectors
public BaseSpqrSchemaGenerator withArgumentInjectors(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.generator.mapping.ArgumentInjector> provider) - Overrides:
withArgumentInjectorsin classio.leangen.graphql.GraphQLSchemaGenerator
-
withModules
- Overrides:
withModulesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withModules
public BaseSpqrSchemaGenerator withModules(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.module.Module> provider) - Overrides:
withModulesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverInterceptors
public BaseSpqrSchemaGenerator withResolverInterceptors(io.leangen.graphql.execution.ResolverInterceptor... interceptors) - Overrides:
withResolverInterceptorsin classio.leangen.graphql.GraphQLSchemaGenerator
-
withResolverInterceptorFactories
public BaseSpqrSchemaGenerator withResolverInterceptorFactories(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, io.leangen.graphql.execution.ResolverInterceptorFactory> provider) - Overrides:
withResolverInterceptorFactoriesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalTypes
@Deprecated public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<graphql.schema.GraphQLType> additionalTypes) Deprecated.- Overrides:
withAdditionalTypesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalTypes
public BaseSpqrSchemaGenerator withAdditionalTypes(Collection<? extends graphql.schema.GraphQLType> additionalTypes, graphql.schema.GraphQLCodeRegistry codeRegistry) - Overrides:
withAdditionalTypesin 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:
withAdditionalDirectivesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalDirectives
- Overrides:
withAdditionalDirectivesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withAdditionalDirectives
public BaseSpqrSchemaGenerator withAdditionalDirectives(graphql.schema.GraphQLDirective... additionalDirectives) - Overrides:
withAdditionalDirectivesin classio.leangen.graphql.GraphQLSchemaGenerator
-
withTypeComparators
public BaseSpqrSchemaGenerator withTypeComparators(io.leangen.graphql.ExtensionProvider<io.leangen.graphql.GeneratorConfiguration, Comparator<AnnotatedType>> provider) - Overrides:
withTypeComparatorsin classio.leangen.graphql.GraphQLSchemaGenerator
-
withOperationBuilder
public BaseSpqrSchemaGenerator withOperationBuilder(io.leangen.graphql.metadata.strategy.query.OperationBuilder operationBuilder) - Overrides:
withOperationBuilderin classio.leangen.graphql.GraphQLSchemaGenerator
-
withDirectiveBuilder
public BaseSpqrSchemaGenerator withDirectiveBuilder(io.leangen.graphql.metadata.strategy.query.DirectiveBuilder directiveBuilder) - Overrides:
withDirectiveBuilderin 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:
withRelayCompliantMutationsin classio.leangen.graphql.GraphQLSchemaGenerator- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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:
withRelayCompliantMutationsin classio.leangen.graphql.GraphQLSchemaGenerator- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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:
withRelayNodeInterfaceInferencein classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
enabled- Whether the inference should be enabled- Returns:
- This
BaseSpqrSchemaGeneratorinstance, to allow method chaining
-
withRelayConnectionCheckRelaxed
Removes the requirement on queries returning a Connection to comply with the Relay Connection spec- Overrides:
withRelayConnectionCheckRelaxedin classio.leangen.graphql.GraphQLSchemaGenerator- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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:
withSchemaProcessorsin classio.leangen.graphql.GraphQLSchemaGenerator- Parameters:
processors- Custom processors to call right before the GraphQL schema is built- Returns:
- This
BaseSpqrSchemaGeneratorinstance, 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 constructGraphQLinstances. See the example in the description of this class.- Overrides:
generatein 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
-