Package graphql.schema.idl
Class SchemaGenerator
java.lang.Object
graphql.schema.idl.SchemaGenerator
This can generate a working runtime schema from a type registry and runtime wiring
The generator uses the RuntimeWiring to insert code that runs behind the schema
elements such as DataFetchers, TypeResolvers
and scalar Coercing.
The order of DataFetcher resolution is as follows:
- If the
WiringFactoryprovides theDataFetcherFactoryfor a field in its parent type then that is used - If the
WiringFactoryprovides theDataFetcherfor a field in its parent type then that is used - If the
RuntimeWiringprovides theDataFetcherfor a field in its parent type, then that is used - If the
RuntimeWiringprovides a defaultDataFetcherfor a fields parent type, then that is used - If the
WiringFactoryprovides a defaultDataFetcherFactoryfor any element then that is used - If the
GraphQLCodeRegistry.Builder.getDefaultDataFetcherFactory()provides aDataFetcherFactoryfor a value then that is used - Finally a
PropertyDataFetcheris used as a last resort for the field
The order of TypeResolver resolution is as follows:
- If the
WiringFactoryprovides aTypeResolverthen that is used - If the
TypeRuntimeWiringprovides aTypeResolverthen that is used
The order of GraphQLScalarType resolution is as follows:
- If the
WiringFactoryprovides aGraphQLScalarTypethen that is used - Otherwise
RuntimeWiring.getScalars()is used
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThese options control how the schema generation works -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphQLSchemaCreated a schema from the SDL that is has a mocked runtime.makeExecutableSchema(SchemaGenerator.Options options, TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) This will take aTypeDefinitionRegistryand aRuntimeWiringand put them together to create a executable schema controlled by the provided options.makeExecutableSchema(TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) This will take aTypeDefinitionRegistryand aRuntimeWiringand put them together to create a executable schema
-
Constructor Details
-
SchemaGenerator
public SchemaGenerator()
-
-
Method Details
-
createdMockedSchema
Created a schema from the SDL that is has a mocked runtime.- Parameters:
sdl- the SDL to be mocked- Returns:
- a schema with a mocked runtime
- See Also:
-
makeExecutableSchema
public GraphQLSchema makeExecutableSchema(TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) throws SchemaProblem This will take aTypeDefinitionRegistryand aRuntimeWiringand put them together to create a executable schema- Parameters:
typeRegistry- this can be obtained viaSchemaParser.parse(String)wiring- this can be built usingRuntimeWiring.newRuntimeWiring()- Returns:
- an executable schema
- Throws:
SchemaProblem- if there are problems in assembling a schema such as missing type resolvers or no operations defined
-
makeExecutableSchema
public GraphQLSchema makeExecutableSchema(SchemaGenerator.Options options, TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) throws SchemaProblem This will take aTypeDefinitionRegistryand aRuntimeWiringand put them together to create a executable schema controlled by the provided options.- Parameters:
options- the controlling optionstypeRegistry- this can be obtained viaSchemaParser.parse(String)wiring- this can be built usingRuntimeWiring.newRuntimeWiring()- Returns:
- an executable schema
- Throws:
SchemaProblem- if there are problems in assembling a schema such as missing type resolvers or no operations defined
-