Skip to content

Commit aacdc39

Browse files
committed
fix test
1 parent c839bf7 commit aacdc39

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/test/groovy/graphql/schema/SchemaTransformerTest.groovy

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ type SubChildChanged {
304304
.name("Query")
305305
.field({ builder ->
306306
builder.name("foo")
307-
.type(Scalars.GraphQLString)
307+
.type(Scalars.GraphQLString)
308308
}).build()
309309

310310
def fooCoordinates = FieldCoordinates.coordinates("Query", "foo")
@@ -347,7 +347,7 @@ type SubChildChanged {
347347
})
348348

349349
def fooTransformedCoordinates = FieldCoordinates.coordinates("Query", "fooChanged")
350-
codeRegistry = codeRegistry.transform({it.dataFetcher(fooTransformedCoordinates, dataFetcher)})
350+
codeRegistry = codeRegistry.transform({ it.dataFetcher(fooTransformedCoordinates, dataFetcher) })
351351
newSchema = newSchema.transform({
352352
builder -> builder.codeRegistry(codeRegistry)
353353
})
@@ -871,7 +871,7 @@ type Query {
871871
@Override
872872
TraversalControl visitGraphQLScalarType(GraphQLScalarType node, TraverserContext<GraphQLSchemaElement> context) {
873873
if (node.getName() == "Foo") {
874-
GraphQLScalarType newNode = node.transform({sc -> sc.name("Bar")})
874+
GraphQLScalarType newNode = node.transform({ sc -> sc.name("Bar") })
875875
return changeNode(context, newNode)
876876
}
877877
return super.visitGraphQLScalarType(node, context)
@@ -901,7 +901,7 @@ type Query {
901901
@Override
902902
TraversalControl visitGraphQLScalarType(GraphQLScalarType node, TraverserContext<GraphQLSchemaElement> context) {
903903
if (node.getName() == "Foo") {
904-
GraphQLScalarType newNode = node.transform({sc -> sc.name("Bar")})
904+
GraphQLScalarType newNode = node.transform({ sc -> sc.name("Bar") })
905905
return changeNode(context, newNode)
906906
}
907907
return super.visitGraphQLScalarType(node, context)
@@ -1056,8 +1056,17 @@ type Query {
10561056
"""
10571057

10581058
def schema = TestUtil.schema(sdl)
1059+
schema = schema.transform { builder ->
1060+
for (def type : schema.getTypeMap().values()) {
1061+
if (type != schema.getQueryType() && type != schema.getMutationType() && type != schema.getSubscriptionType()) {
1062+
builder.additionalType(type)
1063+
}
1064+
}
1065+
}
1066+
10591067

10601068
def visitor = new GraphQLTypeVisitorStub() {
1069+
10611070
@Override
10621071
TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLSchemaElement> context) {
10631072
if (node.hasAppliedDirective("remove")) {
@@ -1075,23 +1084,22 @@ type Query {
10751084
return TraversalControl.CONTINUE
10761085
}
10771086
}
1078-
10791087
when:
10801088
def newSchema = SchemaTransformer.transformSchema(schema, visitor)
1081-
def newSdl = new SchemaPrinter().print(newSchema)
1089+
def printer = new SchemaPrinter(SchemaPrinter.Options.defaultOptions().includeDirectives(false))
1090+
def newSdl = printer.print(newSchema)
10821091

10831092
then:
1084-
newSdl == """
1085-
type Query {
1086-
customer: Customer
1093+
newSdl.trim() == """type Customer {
1094+
rental: Rental
10871095
}
10881096
1089-
type Customer {
1090-
rental: Rental
1097+
type Query {
1098+
customer: Customer
10911099
}
10921100
10931101
type Rental {
10941102
id: ID
1095-
}""".stripIndent().trim()
1103+
}""".trim()
10961104
}
10971105
}

0 commit comments

Comments
 (0)