Skip to content

Commit 8ec7fc3

Browse files
committed
fixing tests
1 parent e60fb5a commit 8ec7fc3

1 file changed

Lines changed: 24 additions & 64 deletions

File tree

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

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package graphql.schema.idl
22

3-
import graphql.AssertException
3+
44
import graphql.TestUtil
55
import graphql.introspection.Introspection
66
import graphql.schema.GraphQLArgument
@@ -25,15 +25,13 @@ import graphql.schema.idl.errors.NotAnInputTypeError
2525
import graphql.schema.idl.errors.NotAnOutputTypeError
2626
import graphql.schema.visibility.GraphqlFieldVisibility
2727
import spock.lang.Specification
28-
import spock.lang.Unroll
2928

3029
import java.util.function.UnaryOperator
3130

3231
import static graphql.Scalars.GraphQLBoolean
3332
import static graphql.Scalars.GraphQLFloat
3433
import static graphql.Scalars.GraphQLInt
3534
import static graphql.Scalars.GraphQLString
36-
import static graphql.schema.GraphQLList.list
3735

3836
class SchemaGeneratorTest extends Specification {
3937

@@ -923,61 +921,6 @@ class SchemaGeneratorTest extends Specification {
923921

924922
}
925923

926-
@Unroll
927-
def "when using implicit directive (w/o definition), #argumentName is supported"() {
928-
setup:
929-
def spec = """
930-
type Query @myDirective($argumentName: $argumentValue) {
931-
foo: String
932-
}
933-
"""
934-
when:
935-
def wiring = RuntimeWiring.newRuntimeWiring()
936-
.build()
937-
938-
def schema = schema(spec, wiring)
939-
def queryType = schema.queryType
940-
941-
then:
942-
def directive = queryType.getDirective("myDirective")
943-
directive.getArgument(argumentName).type == expectedArgumentType
944-
945-
where:
946-
argumentName | argumentValue || expectedArgumentType
947-
"stringArg" | '"a string"' || GraphQLString
948-
"boolArg" | "true" || GraphQLBoolean
949-
"floatArg" | "4.5" || GraphQLFloat
950-
"intArg" | "5" || GraphQLInt
951-
"nullArg" | "null" || GraphQLString
952-
"emptyArrayArg" | "[]" || list(GraphQLString)
953-
"arrayNullsArg" | "[null, null]" || list(GraphQLString)
954-
"arrayArg" | "[3,4,6]" || list(GraphQLInt)
955-
"arrayWithNullsArg" | "[null,3,null,6]" || list(GraphQLInt)
956-
}
957-
958-
@Unroll
959-
def "when using implicit directive (w/o definition), #argumentName is NOT supported"() {
960-
setup:
961-
def spec = """
962-
type Query @myDirective($argumentName: $argumentValue) {
963-
foo: String
964-
}
965-
"""
966-
when:
967-
def wiring = RuntimeWiring.newRuntimeWiring()
968-
.build()
969-
schema(spec, wiring)
970-
971-
then:
972-
def ex = thrown(AssertException)
973-
ex.message == expectedErrorMessage
974-
975-
where:
976-
argumentName | argumentValue || expectedErrorMessage
977-
"objArg" | '{ hi: "John"}' || "Internal error: should never happen: Directive values of type 'ObjectValue' are not supported yet"
978-
"enumArg" | "MONDAY" || "Internal error: should never happen: Directive values of type 'EnumValue' are not supported yet"
979-
"polymorphicArrayArg" | '["one", { hi: "John"}, 5]' || "Arrays containing multiple types of values are not supported yet. Detected the following types [IntValue,ObjectValue,StringValue]"
980-
}
981924

982925
def "deprecated directive is supported"() {
983926
given:
@@ -1153,6 +1096,13 @@ class SchemaGeneratorTest extends Specification {
11531096

11541097
def "object type directives are gathered and turned into runtime objects with arguments"() {
11551098
def spec = """
1099+
directive @directive1 on OBJECT
1100+
directive @fieldDirective1 on FIELD_DEFINITION
1101+
directive @directive2 on OBJECT
1102+
directive @directive3 on OBJECT
1103+
directive @directiveWithArgs(strArg: String, intArg: Int, boolArg: Boolean, floatArg: Float,nullArg: String) on OBJECT
1104+
directive @fieldDirective2 on FIELD_DEFINITION
1105+
11561106
type Query @directive1 {
11571107
field1 : String @fieldDirective1
11581108
}
@@ -1222,18 +1172,21 @@ class SchemaGeneratorTest extends Specification {
12221172
type B {
12231173
fieldB : String
12241174
}
1225-
1175+
directive @IFaceDirective on INTERFACE
12261176
interface IFace @IFaceDirective {
12271177
field1 : String
12281178
}
1229-
1179+
directive @OnionDirective on UNION
12301180
union Onion @OnionDirective = A | B
12311181
1182+
directive @EnumValueDirective on ENUM_VALUE
1183+
directive @NumbDirective on ENUM
12321184
enum Numb @NumbDirective {
12331185
X @EnumValueDirective,
12341186
Y
12351187
}
1236-
1188+
directive @PuterDirective on INPUT_OBJECT
1189+
directive @InputFieldDirective on INPUT_FIELD_DEFINITION
12371190
input Puter @PuterDirective {
12381191
inputField : String @InputFieldDirective
12391192
}
@@ -1351,10 +1304,12 @@ class SchemaGeneratorTest extends Specification {
13511304
}
13521305
13531306
1307+
directive @directive on INTERFACE
13541308
interface IAgeAndHeight @directive {
13551309
age : Int
13561310
}
13571311
1312+
directive @directiveField on FIELD_DEFINITION
13581313
extend interface IAgeAndHeight {
13591314
height : Int @directiveField
13601315
}
@@ -1395,7 +1350,7 @@ class SchemaGeneratorTest extends Specification {
13951350
union FooBar = Foo
13961351
13971352
extend union FooBar = Bar | Baz
1398-
1353+
directive @directive on UNION
13991354
extend union FooBar @directive
14001355
14011356
"""
@@ -1425,7 +1380,7 @@ class SchemaGeneratorTest extends Specification {
14251380
extend enum Numb {
14261381
C
14271382
}
1428-
1383+
directive @directive on ENUM
14291384
extend enum Numb @directive{
14301385
D
14311386
}
@@ -1462,6 +1417,7 @@ class SchemaGeneratorTest extends Specification {
14621417
fieldC : String
14631418
}
14641419
1420+
directive @directive on INPUT_OBJECT
14651421
extend input Puter @directive {
14661422
fieldD : String
14671423
}
@@ -1485,7 +1441,10 @@ class SchemaGeneratorTest extends Specification {
14851441
type Query {
14861442
obj : Object
14871443
}
1488-
1444+
directive @strDirective on ARGUMENT_DEFINITION
1445+
directive @secondDirective on ARGUMENT_DEFINITION
1446+
directive @intDirective(inception: Boolean) on ARGUMENT_DEFINITION
1447+
directive @thirdDirective on ARGUMENT_DEFINITION
14891448
type Object {
14901449
field(argStr : String @strDirective @secondDirective, argInt : Int @intDirective(inception : true) @thirdDirective ) : String
14911450
}
@@ -1778,6 +1737,7 @@ class SchemaGeneratorTest extends Specification {
17781737
17791738
def "extensions are captured into runtime objects"() {
17801739
def sdl = '''
1740+
directive @directive1 on SCALAR
17811741
######## Objects
17821742
17831743
type Query {

0 commit comments

Comments
 (0)