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 DataFetcher
s, TypeResolver
s
and scalar Coercing
.
The order of DataFetcher
resolution is as follows:
- If the
WiringFactory
provides theDataFetcherFactory
for a field in its parent type then that is used - If the
WiringFactory
provides theDataFetcher
for a field in its parent type then that is used - If the
RuntimeWiring
provides theDataFetcher
for a field in its parent type, then that is used - If the
RuntimeWiring
provides a defaultDataFetcher
for a fields parent type, then that is used - If the
WiringFactory
provides a defaultDataFetcherFactory
for any element then that is used - If the
GraphQLCodeRegistry.Builder.getDefaultDataFetcherFactory()
provides aDataFetcherFactory
for a value then that is used - Finally a
PropertyDataFetcher
is used as a last resort for the field
The order of TypeResolver
resolution is as follows:
- If the
WiringFactory
provides aTypeResolver
then that is used - If the
TypeRuntimeWiring
provides aTypeResolver
then that is used
The order of GraphQLScalarType
resolution is as follows:
- If the
WiringFactory
provides aGraphQLScalarType
then that is used - Otherwise
RuntimeWiring.getScalars()
is used
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
These options control how the schema generation works -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphQLSchema
Created a schema from the SDL that is has a mocked runtime.makeExecutableSchema
(SchemaGenerator.Options options, TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) This will take aTypeDefinitionRegistry
and aRuntimeWiring
and put them together to create a executable schema controlled by the provided options.makeExecutableSchema
(TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) This will take aTypeDefinitionRegistry
and aRuntimeWiring
and 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 aTypeDefinitionRegistry
and aRuntimeWiring
and 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 aTypeDefinitionRegistry
and aRuntimeWiring
and 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
-