Skip to main content
Version: 4.x.x

Automatically Created Beans

graphql-kotlin-spring-server automatically creates all the necessary beans to start a GraphQL server. Many of the beans are conditionally created and the default behavior can be customized by providing custom overriding beans in your application context.

Execution

BeanDescription
DataFetcherExceptionHandlerGraphQL exception handler used from the various execution strategies, defaults to SimpleDataFetcherExceptionHandler from graphql-java.
KotlinDataFetcherFactoryProviderFactory used during schema construction to obtain DataFetcherFactory that should be used for target function (using Spring aware SpringDataFetcher) and property resolution.
KotlinDataLoader (optional)Any number of beans created that implement KotlinDataLoader. See Data Loaders for more details.
DataLoaderRegistryFactoryA factory class that creates a DataLoaderRegistry of all the KotlinDataLoaders. Defaults to empty registry.

Non-Federated Schema

note

Created only if federation is disabled

BeanDescription
SchemaGeneratorConfigSchema generator configuration information, see Schema Generator Configuration for details. Can be customized by providing TopLevelNames, SchemaGeneratorHooks and KotlinDataFetcherFactoryProvider beans.
GraphQLSchemaGraphQL schema generated based on the schema generator configuration and Query, Mutation and Subscription objects available in the application context.

Federated Schema

note

Created only if federation is enabled

BeanDescription
FederatedTypeResolversList of FederatedTypeResolvers marked as beans that should be added to hooks. See Federated Type Resolution for more details
FederatedSchemaGeneratorHooksSchema generator hooks used to build federated schema
FederatedSchemaGeneratorConfigFederated schema generator configuration information. You can customize the configuration by providing TopLevelNames, FederatedSchemaGeneratorHooks and KotlinDataFetcherFactoryProvider beans
FederatedTracingInstrumentationIf graphql.federation.tracing.enabled is true, it adds tracing info to the response via the apollo federation-jvm library.
GraphQLSchemaGraphQL schema generated based on the federated schema generator configuration and Query, Mutation and Subscription objects available in the application context.

GraphQL Configuration

BeanDescription
Instrumentation (optional)Any number of beans created that implement graphql-java Instrumentation will be pulled in. The beans can be ordered by implementing the Spring Ordered interface.
ExecutionIdProvider (optional)Any number of beans created that implement graphql-java ExecutionIdProvider will be pulled in.
PreparsedDocumentProvider (optional)Any number of beans created that implement graphql-java PreparsedDocumentProvider will be pulled in.
GraphQLGraphQL execution object generated using GraphQLSchema with default async execution strategies. The GraphQL object can be customized by optionally providing the above beans in the application context.
SpringGraphQLRequestParserProvides the Spring specific logic for parsing the HTTP request into a common GraphQLRequest. See GraphQLRequestParser
SpringGraphQLContextFactorySpring specific factory that uses the ServerRequest. The GraphQLContext generated can be any object. See GraphQLContextFactory.
GraphQLRequestHandlerHandler invoked from GraphQLServer that executes the incoming request, defaults to GraphQLRequestHandler.
SpringGraphQLServerSpring specific object that takes in a ServerRequest and returns a GraphQLResponse using all the above implementations. See GraphQLServer

Subscriptions

note

Created only if the Subscription marker interface is used

BeanDescription
SpringGraphQLSubscriptionHandlerSpring reactor code for executing GraphQL subscriptions requests
WebSocketHandlerAdapterSpring class for handling web socket http requests. See Spring documentation
ApolloSubscriptionHooksProvides hooks into the subscription request lifecycle. See the subscription docs
SpringSubscriptionGraphQLContextFactorySpring specific factory that uses the WebSocketSession. See GraphQLContextFactory.

Fixed Beans

The following beans cannot be overridden, but may have options to disable them:

  • Route handler for GraphQL queries and mutations endpoint.
  • Route handler for the SDL endpoint. Created only if sdl route is enabled.
  • Route handler for Prisma Labs Playground. Created only if playground is enabled
  • Route handler for the subscriptions endpoint. Created only if subscriptions are used.
  • ApolloSubscriptionProtocolHandler for handling GraphQL subscriptions using the graphql-ws protocol. Created only if subscriptions are used.
  • SubscriptionWebSocketHandler that utilizes above subscription protocol handler. Created only if subscriptions are used.