@@ -17,56 +17,59 @@ import java.util.function.BiFunction
1717class DirectiveTest {
1818 @Test
1919 fun `should apply correctly the @uppercase directive` () {
20- val schema = SchemaParser .newParser().schemaString("""
21- directive @uppercase on FIELD_DEFINITION
22-
23- type Query {
24- users: UserConnection
25- }
26-
27- type UserConnection {
28- edges: [UserEdge!]!
29- }
30-
31- type UserEdge {
32- node: User!
33- }
34-
35- type User {
36- id: ID!
37- name: String @uppercase
38- }
39- """ )
40- .resolvers(UsersQueryResolver ())
41- .directive(" uppercase" , UppercaseDirective ())
42- .build()
43- .makeExecutableSchema()
20+ val schema = SchemaParser .newParser()
21+ .schemaString(
22+ """
23+ directive @uppercase on FIELD_DEFINITION
24+
25+ type Query {
26+ users: UserConnection
27+ }
28+
29+ type UserConnection {
30+ edges: [UserEdge!]!
31+ }
32+
33+ type UserEdge {
34+ node: User!
35+ }
36+
37+ type User {
38+ id: ID!
39+ name: String @uppercase
40+ }
41+ """ )
42+ .resolvers(UsersQueryResolver ())
43+ .directive(" uppercase" , UppercaseDirective ())
44+ .build()
45+ .makeExecutableSchema()
4446
4547 val gql = GraphQL .newGraphQL(schema)
46- .queryExecutionStrategy(AsyncExecutionStrategy ())
47- .build()
48-
49- val result = gql.execute("""
50- query {
51- users {
52- edges {
53- node {
54- id
55- name
48+ .queryExecutionStrategy(AsyncExecutionStrategy ())
49+ .build()
50+
51+ val result = gql.execute(
52+ """
53+ query {
54+ users {
55+ edges {
56+ node {
57+ id
58+ name
59+ }
60+ }
5661 }
57- }
5862 }
59- }
60- """ )
63+ """ )
6164
6265 val expected = mapOf (
63- " users" to mapOf (
64- " edges" to listOf (
65- mapOf (" node" to
66- mapOf (" id" to " 1" , " name" to " LUKE" )
67- )
68- )
66+ " users" to mapOf (
67+ " edges" to listOf (
68+ mapOf (" node" to
69+ mapOf (" id" to " 1" , " name" to " LUKE" )
70+ )
6971 )
72+ )
7073 )
7174
7275 Assert .assertEquals(expected, result.getData<Map <String , List <* >>>())
@@ -75,23 +78,25 @@ class DirectiveTest {
7578 @Test
7679 @Ignore(" Ignore until enums work in directives" )
7780 fun `should compile schema with directive that has enum parameter` () {
78- val schema = SchemaParser .newParser().schemaString("""
79- directive @allowed(state: [AllowedState!]) on FIELD_DEFINITION
80-
81- enum AllowedState {
82- ALLOWED
83- DISALLOWED
84- }
85-
86- type Book {
87- id: Int!
88- name: String! @allowed(state: [ALLOWED])
89- }
90-
91- type Query {
92- books: [Book!]
93- }
94- """ )
81+ val schema = SchemaParser .newParser()
82+ .schemaString(
83+ """
84+ directive @allowed(state: [AllowedState!]) on FIELD_DEFINITION
85+
86+ enum AllowedState {
87+ ALLOWED
88+ DISALLOWED
89+ }
90+
91+ type Book {
92+ id: Int!
93+ name: String! @allowed(state: [ALLOWED])
94+ }
95+
96+ type Query {
97+ books: [Book!]
98+ }
99+ """ )
95100 .resolvers(QueryResolver ())
96101 .directive(" allowed" , AllowedDirective ())
97102 .build()
@@ -151,8 +156,8 @@ class DirectiveTest {
151156 }
152157
153158 private data class User (
154- val id : Long ,
155- val name : String
159+ val id : Long ,
160+ val name : String
156161 )
157162 }
158163}
0 commit comments