Class GraphQLPluginBuilder
-
- All Implemented Interfaces:
public final class GraphQLPluginBuilderBuilds the GraphQL schema and the pieces the plugin needs to serve it. This is the only way to configure the plugin:
config.registerPlugin( GraphQLPluginBuilder("/graphql") .addPackage("com.example.schema") .register(QueryExample()) .build() )Both context factories are optional and default to an empty
GraphQLContext. The@JvmOverloadsis what makesnew GraphQLPluginBuilder("/graphql")compile from Java, where Kotlin's default arguments do not exist. Java callers realistically use the defaults:GraphQLContextFactory.generateContextis asuspendfunction, which is not implementable from Java in practice.Note that since graphql-kotlin 6 the context is graphql-java's map-like
GraphQLContext, so this class no longer carries a context type parameter (ADR-001).
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringpathprivate final GraphQLContextFactory<Context>contextFactoryprivate final GraphQLContextFactory<WsMessageContext>contextWsFactory
-
Constructor Summary
Constructors Constructor Description GraphQLPluginBuilder(String path, GraphQLContextFactory<Context> contextFactory, GraphQLContextFactory<WsMessageContext> contextWsFactory)GraphQLPluginBuilder(String path, GraphQLContextFactory<Context> contextFactory)GraphQLPluginBuilder(String path)
-
Method Summary
Modifier and Type Method Description final StringgetPath()final GraphQLContextFactory<Context>getContextFactory()final GraphQLContextFactory<WsMessageContext>getContextWsFactory()final GraphQLPluginBuilderaddPackage(String aPackage)Adds a package for graphql-kotlin to scan when it resolves interface and union subtypes. final GraphQLPluginBuilderdisableGraphiQL()Stops the plugin from serving GraphiQL, leaving only the POSTendpoint and the subscription WebSocket.final GraphQLPluginBuilderregister(KotlinDataLoader<?, ?> dataLoaders)final GraphQLPluginBuilderregister(QueryGraphql queries)final GraphQLPluginBuilderregister(MutationGraphql mutations)final GraphQLPluginBuilderregister(SubscriptionGraphql subscriptions)final GraphQLPluginbuild()-
-
Constructor Detail
-
GraphQLPluginBuilder
GraphQLPluginBuilder(String path, GraphQLContextFactory<Context> contextFactory, GraphQLContextFactory<WsMessageContext> contextWsFactory)
-
GraphQLPluginBuilder
GraphQLPluginBuilder(String path, GraphQLContextFactory<Context> contextFactory)
-
GraphQLPluginBuilder
GraphQLPluginBuilder(String path)
-
-
Method Detail
-
getContextFactory
final GraphQLContextFactory<Context> getContextFactory()
-
getContextWsFactory
final GraphQLContextFactory<WsMessageContext> getContextWsFactory()
-
addPackage
final GraphQLPluginBuilder addPackage(String aPackage)
Adds a package for graphql-kotlin to scan when it resolves interface and union subtypes. Sub-packages are included. At least one package is required.
-
disableGraphiQL
final GraphQLPluginBuilder disableGraphiQL()
Stops the plugin from serving GraphiQL, leaving only the
POSTendpoint and the subscription WebSocket. An application that does not want to publish a schema explorer has no other way to say so, since the routes are registered by the plugin itself.
-
register
final GraphQLPluginBuilder register(KotlinDataLoader<?, ?> dataLoaders)
-
register
final GraphQLPluginBuilder register(QueryGraphql queries)
-
register
final GraphQLPluginBuilder register(MutationGraphql mutations)
-
register
final GraphQLPluginBuilder register(SubscriptionGraphql subscriptions)
-
build
final GraphQLPlugin build()
-
-
-
-