Class SchemaMappingInspector

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

public final class SchemaMappingInspector extends Object
Declares an inspect(GraphQLSchema, RuntimeWiring) method that checks if schema mappings.

Schema mapping checks depend on DataFetchers to be SelfDescribingDataFetcher in order to compare schema type and Java object type structure. If a DataFetcher does not implement this interface, then the Java type remains unknown, and the field type is reported as "skipped".

The SelfDescribingDataFetcher for an annotated controller method derives type information from the controller method signature. If the declared return type is Object, or an unspecified generic parameter such as List<?> then the Java type structure remains unknown, and the field output type is reported as skipped.

Unions are always skipped because there is no way for an annotated controller method to express that in a return type, and the Java type structure remains unknown.

Interfaces are supported only as far as fields declared directly on the interface, which are compared against properties of the Java type declared by a SelfDescribingDataFetcher.

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 one once only, during the first call to this method.
    • inspect

      public static SchemaReport inspect(GraphQLSchema schema, 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(GraphQLSchema schema, Map<String,Map<String,DataFetcher>> dataFetchers)
      Variant of inspect(GraphQLSchema, RuntimeWiring) with a map of DataFetcher registrations.
      Parameters:
      schema - the schema to inspect
      dataFetchers - the map of registered DataFetcher instances
      Since:
      1.2.5