Skip to main content
Version: 3.x.x

Automatically Created Beans

graphql-kotlin-spring-server automatically creates all the necessary beans to start GraphQL web server. Many of the beans are conditionally created and default behavior can be customized by providing custom beans in your application context. See sections below for the information about all automatically created beans.

Schema Generation

BeanDescription
FederatedSchemaGeneratorHooksSchema generator hooks used to build federated schema.

Created only if federation is enabled.
FederatedSchemaGeneratorConfigFederated schema generator configuration information. You can customize the configuration by providing TopLevelNames, FederatedSchemaGeneratorHooks and KotlinDataFetcherFactoryProvider beans.

Created instead of default SchemaGeneratorConfig if federation is enabled.
FederatedTypeRegistryDefault type registry without any resolvers. See Federated Type Resolution for more details.

Created only if federation is enabled. You should register your custom type registry bean whenever implementing federated GraphQL schema with extended types.
GraphQLSchemaGraphQL schema generated based on the schema generator configuration and Query, Mutation and Subscription objects available in the application context.
KotlinDataFetcherFactoryProviderFactory used during schema construction to obtain DataFetcherFactory that should be used for target function (using Spring aware SpringDataFetcher) and property resolution.
SchemaGeneratorConfigSchema generator configuration information, see Schema Generator Configuration for details. Can be customized by providing TopLevelNames, SchemaGeneratorHooks and KotlinDataFetcherFactoryProvider beans.

Execution

BeanDescription
ContextWebFilterDefault web filter that populates GraphQL context in the reactor subscriber context.
DataFetcherExceptionHandlerGraphQL exception handler used from the various execution strategies, defaults to KotlinDataFetcherExceptionHandler.
DataLoaderRegistryFactoryFactory used to create DataLoaderRegistry instance per query execution. See graphql-java documentation for more details.
GraphQLGraphQL query execution engine generated using GraphQLSchema with default async execution strategies. GraphQL engine can be customized by optionally providing a list of Instrumentation beans (which can be ordered by implementing Spring Ordered interface), ExecutionIdProvider and PreparsedDocumentProvider in the application context.
GraphQLContextFactoryFactory used by context WebFilter to generate GraphQL context based on the incoming request. GraphQL context can be any object. Defaults to empty GraphQLContext.
QueryHandlerHandler invoked from GraphQL query route that executes the incoming request, defaults to SimpleQueryHandler.
SubscriptionHandlerWeb socket handler for executing GraphQL subscriptions, defaults to SimpleSubscriptionHandler.

Created only if Subscription bean is available in the context.
WebSocketHandlerAdapterSee Spring documentation.

Created only if Subscription bean is available in the context.

The following beans are currently automatically created and cannot be disabled:

  • Default routes for GraphQL queries/mutations and SDL endpoint
  • Default route for Prisma Labs Playground, created only if playground is enabled
  • Default ApolloSubscriptionProtocolHandler for handling GraphQL subscriptions, created only if Subscription bean is available in the context
  • Default SubscriptionWebSocketHandler that utilizes above subscription protocol handler, created only if Subscription bean is available in the context
  • Default subscription handler mapping, created only if Subscription bean is available in the context