Class GraphQLSchema.Builder
- Enclosing class:
GraphQLSchema
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadditionalDirective(GraphQLDirective additionalDirective) additionalDirectives(Set<GraphQLDirective> additionalDirectives) additionalType(GraphQLNamedType additionalType) Adds a single type to the set of additional types.additionalTypes(Set<? extends GraphQLNamedType> additionalTypes) Adds multiple types to the set of additional types.build()Builds the schemaClears all additional types that have been added to this builder.This is used to clear all the directives in the builder so far.codeRegistry(GraphQLCodeRegistry codeRegistry) definition(SchemaDefinition definition) description(String description) extensionDefinitions(List<SchemaExtensionDefinition> extensionDefinitions) introspectionSchemaType(GraphQLObjectType introspectionSchemaType) mutation(GraphQLObjectType mutationType) mutation(GraphQLObjectType.Builder builder) query(GraphQLObjectType queryType) query(GraphQLObjectType.Builder builder) subscription(GraphQLObjectType subscriptionType) subscription(GraphQLObjectType.Builder builder) withSchemaAppliedDirective(GraphQLAppliedDirective appliedDirective) withSchemaAppliedDirectives(GraphQLAppliedDirective... appliedDirectives) withSchemaAppliedDirectives(Collection<? extends GraphQLAppliedDirective> appliedDirectives) withSchemaDirective(GraphQLDirective directive) withSchemaDirectives(GraphQLDirective... directives) withSchemaDirectives(Collection<? extends GraphQLDirective> directives)
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
query
-
query
-
mutation
-
mutation
-
subscription
-
subscription
-
codeRegistry
-
additionalTypes
Adds multiple types to the set of additional types.Additional types are types that may not be directly reachable by traversing the schema from the root operation types (Query, Mutation, Subscription), but still need to be included in the schema. The most common use case is for object types that implement an interface but are not directly referenced as field return types.
Example - Adding interface implementations:
// If Node interface is used but User/Post types aren't directly referenced: builder.additionalTypes(Set.of( GraphQLObjectType.newObject().name("User").withInterface(nodeInterface)..., GraphQLObjectType.newObject().name("Post").withInterface(nodeInterface)... ));Note: There are no restrictions on what types can be added. Types already reachable from root operations can be added without causing errors - they will simply exist in both the traversed type map and this set.
- Parameters:
additionalTypes- the types to add- Returns:
- this builder
- See Also:
-
additionalType
Adds a single type to the set of additional types.Additional types are types that may not be directly reachable by traversing the schema from the root operation types (Query, Mutation, Subscription), but still need to be included in the schema. The most common use case is for object types that implement an interface but are not directly referenced as field return types.
Note: There are no restrictions on what types can be added. Types already reachable from root operations can be added without causing errors.
- Parameters:
additionalType- the type to add- Returns:
- this builder
- See Also:
-
clearAdditionalTypes
Clears all additional types that have been added to this builder.This is useful when transforming an existing schema and you want to rebuild the additional types set from scratch.
- Returns:
- this builder
- See Also:
-
additionalDirectives
-
additionalDirective
-
withSchemaDirectives
-
withSchemaDirectives
public GraphQLSchema.Builder withSchemaDirectives(Collection<? extends GraphQLDirective> directives) -
withSchemaDirective
-
withSchemaDirective
-
withSchemaAppliedDirectives
public GraphQLSchema.Builder withSchemaAppliedDirectives(GraphQLAppliedDirective... appliedDirectives) -
withSchemaAppliedDirectives
public GraphQLSchema.Builder withSchemaAppliedDirectives(Collection<? extends GraphQLAppliedDirective> appliedDirectives) -
withSchemaAppliedDirective
-
withSchemaAppliedDirective
-
clearSchemaDirectives
This is used to clear all the directives in the builder so far.- Returns:
- the builder
-
definition
-
extensionDefinitions
public GraphQLSchema.Builder extensionDefinitions(List<SchemaExtensionDefinition> extensionDefinitions) -
description
-
introspectionSchemaType
-
build
Builds the schema- Returns:
- the built schema
-