Class GraphQl.Builder

java.lang.Object
com.jsgalactic.axiom.graphql.GraphQl.Builder
Enclosing class:
GraphQl

public static final class GraphQl.Builder extends Object
Builds a GraphQl; not thread-safe, build once at startup.
  • Method Details

    • schema

      public GraphQl.Builder schema(String sdl)
      Sets the SDL schema. It is parsed and validated when build() runs.
      Parameters:
      sdl - GraphQL schema definition language, non-blank
      Returns:
      this builder
    • graphQL

      public GraphQl.Builder graphQL(Object graphQL)
      Supplies the application-owned runtime. The value must be a graphql.GraphQL; anything else fails the build. The instance is never modified: the adapter derives a transform that adds its own instrumentation around the existing configuration.
      Parameters:
      graphQL - application-owned graphql.GraphQL instance
      Returns:
      this builder
    • options

      public GraphQl.Builder options(GraphQlOptions options)
      Sets request and query bounds. Defaults to GraphQlOptions.DEFAULT.
      Parameters:
      options - immutable bounds
      Returns:
      this builder
    • dataLoaders

      public GraphQl.Builder dataLoaders(Supplier<Object> dataLoaders)
      Sets a factory for the per-request DataLoader registry. It must return a org.dataloader.DataLoaderRegistry; the parameter and result are typed as Object so no graphql-java type appears in this API. Without a factory each request gets a fresh empty registry.
      Parameters:
      dataLoaders - thread-safe factory called once per request
      Returns:
      this builder
    • build

      public GraphQl build()
      Parses the schema, composes the instrumentation and builds the handler.
      Returns:
      an immutable adapter
      Throws:
      IllegalArgumentException - if the SDL or the supplied runtime is invalid
      IllegalStateException - if no schema was supplied