Skip to content

Commit 5eb4e1a

Browse files
committed
Polishing in GraphQlSource.Builder implementations
1 parent 8ec513b commit 5eb4e1a

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

spring-graphql/src/main/java/org/springframework/graphql/execution/AbstractGraphQlSourceBuilder.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,7 @@ private GraphQLSchema applyTypeVisitors(GraphQLSchema schema) {
149149
/**
150150
* {@link GraphQlSource} with fixed {@link GraphQL} and {@link GraphQLSchema} instances.
151151
*/
152-
private static class FixedGraphQlSource implements GraphQlSource {
153-
154-
private final GraphQL graphQl;
155-
156-
private final GraphQLSchema schema;
157-
158-
FixedGraphQlSource(GraphQL graphQl, GraphQLSchema schema) {
159-
this.graphQl = graphQl;
160-
this.schema = schema;
161-
}
162-
163-
@Override
164-
public GraphQL graphQl() {
165-
return this.graphQl;
166-
}
167-
168-
@Override
169-
public GraphQLSchema schema() {
170-
return this.schema;
171-
}
172-
152+
private record FixedGraphQlSource(GraphQL graphQl, GraphQLSchema schema) implements GraphQlSource {
173153
}
174154

175155
}

spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ final class DefaultSchemaResourceGraphQlSourceBuilder
6060

6161
private final Set<Resource> schemaResources = new LinkedHashSet<>();
6262

63-
private List<TypeDefinitionConfigurer> typeDefinitionConfigurers = new ArrayList<>();
63+
private final List<TypeDefinitionConfigurer> typeDefinitionConfigurers = new ArrayList<>();
6464

6565
private final List<RuntimeWiringConfigurer> runtimeWiringConfigurers = new ArrayList<>();
6666

@@ -133,6 +133,9 @@ protected GraphQLSchema initGraphQlSchema() {
133133
}
134134
});
135135

136+
// SchemaMappingInspector needs RuntimeWiring, but cannot run here since type
137+
// visitors may transform the schema, for example to add Connection types.
138+
136139
configureGraphQl(builder -> {
137140
GraphQLSchema schema = builder.build().getGraphQLSchema();
138141
SchemaMappingInspector.Report report = SchemaMappingInspector.inspect(schema, runtimeWiring);

spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,8 @@
2929
* @author Rossen Stoyanchev
3030
* @since 1.0.0
3131
*/
32-
final class ExternalSchemaGraphQlSourceBuilder extends AbstractGraphQlSourceBuilder<ExternalSchemaGraphQlSourceBuilder>
32+
final class ExternalSchemaGraphQlSourceBuilder
33+
extends AbstractGraphQlSourceBuilder<ExternalSchemaGraphQlSourceBuilder>
3334
implements GraphQlSource.Builder<ExternalSchemaGraphQlSourceBuilder> {
3435

3536
private final GraphQLSchema schema;

0 commit comments

Comments
 (0)