diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/AbstractGraphQlSourceBuilder.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/AbstractGraphQlSourceBuilder.java index 0698e48d..6aefeaa5 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/AbstractGraphQlSourceBuilder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/AbstractGraphQlSourceBuilder.java @@ -149,27 +149,7 @@ abstract class AbstractGraphQlSourceBuilder> /** * {@link GraphQlSource} with fixed {@link GraphQL} and {@link GraphQLSchema} instances. */ - private static class FixedGraphQlSource implements GraphQlSource { - - private final GraphQL graphQl; - - private final GraphQLSchema schema; - - FixedGraphQlSource(GraphQL graphQl, GraphQLSchema schema) { - this.graphQl = graphQl; - this.schema = schema; - } - - @Override - public GraphQL graphQl() { - return this.graphQl; - } - - @Override - public GraphQLSchema schema() { - return this.schema; - } - + private record FixedGraphQlSource(GraphQL graphQl, GraphQLSchema schema) implements GraphQlSource { } } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java index 57a2689b..ffb94dee 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java @@ -60,7 +60,7 @@ final class DefaultSchemaResourceGraphQlSourceBuilder private final Set schemaResources = new LinkedHashSet<>(); - private List typeDefinitionConfigurers = new ArrayList<>(); + private final List typeDefinitionConfigurers = new ArrayList<>(); private final List runtimeWiringConfigurers = new ArrayList<>(); @@ -133,6 +133,9 @@ final class DefaultSchemaResourceGraphQlSourceBuilder } }); + // SchemaMappingInspector needs RuntimeWiring, but cannot run here since type + // visitors may transform the schema, for example to add Connection types. + configureGraphQl(builder -> { GraphQLSchema schema = builder.build().getGraphQLSchema(); SchemaMappingInspector.Report report = SchemaMappingInspector.inspect(schema, runtimeWiring); diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java index d1eefcdf..e4170a95 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,8 @@ import org.springframework.util.Assert; * @author Rossen Stoyanchev * @since 1.0.0 */ -final class ExternalSchemaGraphQlSourceBuilder extends AbstractGraphQlSourceBuilder +final class ExternalSchemaGraphQlSourceBuilder + extends AbstractGraphQlSourceBuilder implements GraphQlSource.Builder { private final GraphQLSchema schema;