Package graphql.schema.idl
Class SchemaGenerator
- java.lang.Object
-
- graphql.schema.idl.SchemaGenerator
-
@PublicApi public class SchemaGenerator extends java.lang.Object
This can generate a working runtime schema from a type registry and runtime wiringThe generator uses the
RuntimeWiring
to insert code that runs behind the schema elements such asDataFetcher
s,TypeResolver
s and scalarCoercing
.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
- If the
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchemaGenerator.Options
These options control how the schema generation works
-
Constructor Summary
Constructors Constructor Description SchemaGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GraphQLSchema
createdMockedSchema(java.lang.String sdl)
Created a schema from the SDL that is has a mocked runtime.GraphQLSchema
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.GraphQLSchema
makeExecutableSchema(TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring)
This will take aTypeDefinitionRegistry
and aRuntimeWiring
and put them together to create a executable schema
-
-
-
Method Detail
-
createdMockedSchema
public static GraphQLSchema createdMockedSchema(java.lang.String sdl)
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:
RuntimeWiring.MOCKED_WIRING
-
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
-
-