Skip to content

Commit 619083a

Browse files
authored
Merge pull request #1734 from graphql-java/schema-generator-post-process
rename SDL schema transformer into SchemaGeneratorPostProcessing
2 parents b5692e4 + dd44da9 commit 619083a

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/main/java/graphql/schema/GraphQLSchema.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public GraphQLDirective getDirective(String name) {
257257

258258
/**
259259
* This returns the list of directives that have been explicitly put on the
260-
* schema object. Note that {@link {@link #getDirectives()}} will return
260+
* schema object. Note that {@link #getDirectives()} will return
261261
* directives for all schema elements, whereas this is just for the schema
262262
* element itself
263263
*
@@ -269,7 +269,7 @@ public List<GraphQLDirective> getSchemaDirectives() {
269269

270270
/**
271271
* This returns a map of directives that have been explicitly put on the
272-
* schema object. Note that {@link {@link #getDirectives()}} will return
272+
* schema object. Note that {@link #getDirectives()} will return
273273
* directives for all schema elements, whereas this is just for the schema
274274
* element itself
275275
*
@@ -281,7 +281,7 @@ public Map<String, GraphQLDirective> getSchemaDirectiveByName() {
281281

282282
/**
283283
* This returns the named directive that have been explicitly put on the
284-
* schema object. Note that {@link {@link #getDirective(String)} ()}} will return
284+
* schema object. Note that {@link #getDirective(String)} will return
285285
* directives for all schema elements, whereas this is just for the schema
286286
* element itself
287287
*

src/main/java/graphql/schema/idl/RuntimeWiring.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class RuntimeWiring {
3434
private final List<SchemaDirectiveWiring> directiveWiring;
3535
private final WiringFactory wiringFactory;
3636
private final Map<String, EnumValuesProvider> enumValuesProviders;
37-
private final Collection<SchemaTransformer> schemaTransformers;
37+
private final Collection<SchemaGeneratorPostProcessing> schemaGeneratorPostProcessings;
3838
private final GraphqlFieldVisibility fieldVisibility;
3939
private final GraphQLCodeRegistry codeRegistry;
4040
private final GraphqlTypeComparatorRegistry comparatorRegistry;
@@ -48,7 +48,7 @@ private RuntimeWiring(Builder builder) {
4848
this.directiveWiring = builder.directiveWiring;
4949
this.wiringFactory = builder.wiringFactory;
5050
this.enumValuesProviders = builder.enumValuesProviders;
51-
this.schemaTransformers = builder.schemaTransformers;
51+
this.schemaGeneratorPostProcessings = builder.schemaGeneratorPostProcessings;
5252
this.fieldVisibility = builder.fieldVisibility;
5353
this.codeRegistry = builder.codeRegistry;
5454
this.comparatorRegistry = builder.comparatorRegistry;
@@ -105,8 +105,8 @@ public List<SchemaDirectiveWiring> getDirectiveWiring() {
105105
return directiveWiring;
106106
}
107107

108-
public Collection<SchemaTransformer> getSchemaTransformers() {
109-
return schemaTransformers;
108+
public Collection<SchemaGeneratorPostProcessing> getSchemaGeneratorPostProcessings() {
109+
return schemaGeneratorPostProcessings;
110110
}
111111

112112
public GraphqlTypeComparatorRegistry getComparatorRegistry() {
@@ -122,7 +122,7 @@ public static class Builder {
122122
private final Map<String, EnumValuesProvider> enumValuesProviders = new LinkedHashMap<>();
123123
private final Map<String, SchemaDirectiveWiring> registeredDirectiveWiring = new LinkedHashMap<>();
124124
private final List<SchemaDirectiveWiring> directiveWiring = new ArrayList<>();
125-
private final Collection<SchemaTransformer> schemaTransformers = new ArrayList<>();
125+
private final Collection<SchemaGeneratorPostProcessing> schemaGeneratorPostProcessings = new ArrayList<>();
126126
private WiringFactory wiringFactory = new NoopWiringFactory();
127127
private GraphqlFieldVisibility fieldVisibility = DEFAULT_FIELD_VISIBILITY;
128128
private GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry.newCodeRegistry().build();
@@ -304,12 +304,12 @@ public Builder comparatorRegistry(GraphqlTypeComparatorRegistry comparatorRegist
304304
/**
305305
* Adds a schema transformer into the mix
306306
*
307-
* @param schemaTransformer the non null schema transformer to add
307+
* @param schemaGeneratorPostProcessing the non null schema transformer to add
308308
*
309309
* @return the runtime wiring builder
310310
*/
311-
public Builder transformer(SchemaTransformer schemaTransformer) {
312-
this.schemaTransformers.add(assertNotNull(schemaTransformer));
311+
public Builder transformer(SchemaGeneratorPostProcessing schemaGeneratorPostProcessing) {
312+
this.schemaGeneratorPostProcessings.add(assertNotNull(schemaGeneratorPostProcessing));
313313
return this;
314314
}
315315

src/main/java/graphql/schema/idl/SchemaGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ private GraphQLSchema makeExecutableSchemaImpl(BuildContext buildCtx) {
293293

294294
GraphQLSchema graphQLSchema = schemaBuilder.build();
295295

296-
Collection<SchemaTransformer> schemaTransformers = buildCtx.getWiring().getSchemaTransformers();
297-
for (SchemaTransformer schemaTransformer : schemaTransformers) {
298-
graphQLSchema = schemaTransformer.transform(graphQLSchema);
296+
Collection<SchemaGeneratorPostProcessing> schemaTransformers = buildCtx.getWiring().getSchemaGeneratorPostProcessings();
297+
for (SchemaGeneratorPostProcessing postProcessing : schemaTransformers) {
298+
graphQLSchema = postProcessing.process(graphQLSchema);
299299
}
300300
return graphQLSchema;
301301
}

src/main/java/graphql/schema/idl/SchemaTransformer.java renamed to src/main/java/graphql/schema/idl/SchemaGeneratorPostProcessing.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* These are called by the {@link SchemaGenerator} after a valid schema has been built
77
* and they can then adjust it accordingly with some sort of post processing.
88
*/
9-
public interface SchemaTransformer {
9+
public interface SchemaGeneratorPostProcessing {
1010

1111
/**
1212
* Called to transform the schema from its built state into something else
@@ -15,5 +15,5 @@ public interface SchemaTransformer {
1515
*
1616
* @return a non null schema
1717
*/
18-
GraphQLSchema transform(GraphQLSchema originalSchema);
18+
GraphQLSchema process(GraphQLSchema originalSchema);
1919
}

src/test/groovy/graphql/schema/idl/SchemaGeneratorTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,9 @@ class SchemaGeneratorTest extends Specification {
17411741
17421742
def extraDirective = (GraphQLDirective.newDirective()).name("extra")
17431743
.argument(GraphQLArgument.newArgument().name("value").type(GraphQLString)).build()
1744-
def transformer = new SchemaTransformer() {
1744+
def transformer = new SchemaGeneratorPostProcessing() {
17451745
@Override
1746-
GraphQLSchema transform(GraphQLSchema originalSchema) {
1746+
GraphQLSchema process(GraphQLSchema originalSchema) {
17471747
originalSchema.transform({ builder -> builder.additionalDirective(extraDirective) })
17481748
}
17491749
}

0 commit comments

Comments
 (0)