Skip to main content
Version: pre-release

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.
KotlinDataLoaderRegistryFactoryA factory class that creates a KotlinDataLoaderRegistry of all the KotlinDataLoaders. Defaults to empty registry.

Non-Federated Schema

note

Created only if federation is disabled

BeanDescription
GraphQLSchemaGraphQL schema generated based on the schema generator configuration and Query, Mutation and Subscription objects available in the application context.
SchemaGeneratorConfigSchema generator configuration information, see Schema Generator Configuration for details. Can be customized by providing TopLevelNames, SchemaGeneratorHooks and KotlinDataFetcherFactoryProvider beans.
GraphQLTypeResolverGraphQL type resolver that is used to lookup polymorphic type hierarchy. Defaults to use ClassGraph to load polymorphic information directly from classpath.

NOTE: When generating GraalVM Native Images you cannot use classpath scanning and have to explicitly provide this information.

Federated Schema

note

Created only if federation is enabled

BeanDescription
FederatedGraphQLTypeResolverGraphQL type resolver that is used to lookup polymorphic type hierarchy and locate federated entities. Defaults to use ClassGraph to load information directly from classpath.

NOTE: When generating GraalVM Native Images you cannot use classpath scanning and have to explicitly provide this information.
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
IDValueUnboxerValue unboxer that provides support for handling ID value class

Subscriptions

note

Created only if the Subscription marker interface is used

BeanDescription
FlowSubscriptionSchemaGeneratorHooksSchema generator hooks that provide support for using Flow in your subscriptions
WebSocketHandlerAdapterSpring class for handling web socket http requests. See Spring documentation
HandlerMappingMaps websocket URL to the corresponding web socket handler

graphql-transport-ws

BeanDescription
SpringSubscriptionGraphQLContextFactoryGenerates GraphQL subscription context based on the WebSocket session information
SpringGraphQLSubscriptionRequestParserParses incoming WebSocket messages
SpringGraphQLSubscriptionHooksProvides hooks into the subscription request lifecycle
SubscriptionWebSocketHandlerWebSocketHandler that implements the graphql-transport-ws subscription protocol

(deprecated) subscription-transport-ws

BeanDescription
ApolloSubscriptionHooksProvides hooks into the subscription request lifecycle. See the subscription docs
SpringSubscriptionGraphQLContextFactorySpring specific factory that uses the WebSocketSession. See GraphQLContextFactory.
ApolloSubscriptionProtocolHandlerImplementation of the subscription-transport-ws subscription protocol
ApolloSubscriptionWebSocketHandlerWebSocketHandler that delegates handling of the messages to the ApolloSubscriptionProtocolHandler bean

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 GraphQL graphiql browser IDE. Created only if graphiql 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.