Class SchemaMappingInspector
java.lang.Object
org.springframework.graphql.execution.SchemaMappingInspector
Inspect schema mappings on startup to ensure the following:
- Schema fields have either a
DataFetcherregistration or a corresponding Class property. DataFetcherregistrations refer to a schema field that exists.DataFetcherarguments have matching schema field arguments.- The nullness of
DataFetcherreturn types, class properties or class methods match, or is more restrictive than, the nullness of schema fields. - The nullness of
DataFetcherarguments match, or is more restrictive than, the nullness of schema argument types.
Use methods of GraphQlSource.SchemaResourceBuilder to enable schema
inspection on startup. For all other cases, use initializer() as a
starting point or the shortcut inspect(GraphQLSchema, Map).
- Since:
- 1.2.0
- Author:
- Brian Clozel, Rossen Stoyanchev
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceStrategy to resolve the Java class(es) for aGraphQLObjectType, effectively the reverse ofTypeResolver, for schema inspection purposes.static interfaceHelps to configureSchemaMappingInspector. -
Method Summary
Modifier and TypeMethodDescriptionPerform an inspection and create aSchemaReport.Return an initializer to configure theSchemaMappingInspectorand perform the inspection.static SchemaReportinspect(graphql.schema.GraphQLSchema schema, graphql.schema.idl.RuntimeWiring runtimeWiring) Check the schema againstDataFetcherregistrations, and produce a report.static SchemaReportinspect(graphql.schema.GraphQLSchema schema, Map<String, Map<String, graphql.schema.DataFetcher>> fetchers) Variant ofinspect(GraphQLSchema, RuntimeWiring)with a map ofDataFetcherregistrations.
-
Method Details
-
getOrCreateReport
Perform an inspection and create aSchemaReport. The inspection is done once only, during the first call to this method. -
inspect
public static SchemaReport inspect(graphql.schema.GraphQLSchema schema, graphql.schema.idl.RuntimeWiring runtimeWiring) Check the schema againstDataFetcherregistrations, and produce a report.- Parameters:
schema- the schema to inspectruntimeWiring- forDataFetcherregistrations- Returns:
- the created report
-
inspect
public static SchemaReport inspect(graphql.schema.GraphQLSchema schema, Map<String, Map<String, graphql.schema.DataFetcher>> fetchers) Variant ofinspect(GraphQLSchema, RuntimeWiring)with a map ofDataFetcherregistrations.- Parameters:
schema- the schema to inspectfetchers- the map ofDataFetcherregistrations- Since:
- 1.2.5
-
initializer
Return an initializer to configure theSchemaMappingInspectorand perform the inspection.- Since:
- 1.3.0
-