Class SchemaMappingInspector

java.lang.Object
org.springframework.graphql.execution.SchemaMappingInspector

public final class SchemaMappingInspector extends Object
Inspect schema mappings on startup to ensure the following:
  • Schema fields have either a DataFetcher registration or a corresponding Class property.
  • DataFetcher registrations refer to a schema field that exists.
  • DataFetcher arguments have matching schema field arguments.
  • The nullness of schema fields matches the nullness of DataFetcher return types, class properties or class methods.
  • DataFetcher arguments match 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
  • Method Details

    • getOrCreateReport

      public SchemaReport getOrCreateReport()
      Perform an inspection and create a SchemaReport. 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 against DataFetcher registrations, and produce a report.
      Parameters:
      schema - the schema to inspect
      runtimeWiring - for DataFetcher registrations
      Returns:
      the created report
    • inspect

      public static SchemaReport inspect(graphql.schema.GraphQLSchema schema, Map<String, Map<String, graphql.schema.DataFetcher>> fetchers)
      Variant of inspect(GraphQLSchema, RuntimeWiring) with a map of DataFetcher registrations.
      Parameters:
      schema - the schema to inspect
      fetchers - the map of DataFetcher registrations
      Since:
      1.2.5
    • initializer

      public static SchemaMappingInspector.Initializer initializer()
      Return an initializer to configure the SchemaMappingInspector and perform the inspection.
      Since:
      1.3.0