File tree Expand file tree Collapse file tree 11 files changed +118
-1
lines changed
kotlin/graphql/kickstart/tools/place Expand file tree Collapse file tree 11 files changed +118
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
<groupId >com.graphql-java-kickstart</groupId >
6
6
<artifactId >graphql-java-tools</artifactId >
7
- <version >5.7.2 -SNAPSHOT</version >
7
+ <version >5.7.3 -SNAPSHOT</version >
8
8
<packaging >jar</packaging >
9
9
10
10
<name >GraphQL Java Tools</name >
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ abstract class Entity (val id : String? = null )
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ abstract class OtherPlace <R : Review <* >>(id : String? = null ) : Place<R>(id) {
4
+
5
+ val other: String? = null
6
+
7
+ }
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ abstract class Place <R : Review <* >>(id : String? = null ) : Entity(id) {
4
+
5
+ val name: String? = null
6
+ val reviews: MutableSet <R >? = null
7
+
8
+ }
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ class Place1 (id : String? = null ) : OtherPlace<Review1>(id)
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ class Place2 (id : String? = null ) : OtherPlace<Review2>(id)
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ import graphql.ExecutionInput
4
+ import graphql.GraphQL
5
+ import graphql.kickstart.tools.GraphQLQueryResolver
6
+ import graphql.kickstart.tools.SchemaParser
7
+ import org.junit.Test
8
+
9
+ class PlaceQuery : GraphQLQueryResolver {
10
+ fun places1 (): List <Place1 > = listOf (Place1 (" 1" ), Place1 (" 2" ), Place1 (" 3" ))
11
+ fun places2 (): List <Place2 > = listOf (Place2 (" 4" ), Place2 (" 5" ))
12
+ }
13
+
14
+ class PlaceTest {
15
+
16
+ @Test
17
+ fun shouldHandleGenericsDeepHierarchy () {
18
+ val schema = SchemaParser .newParser()
19
+ .file(" place.graphqls" )
20
+ .resolvers(PlaceQuery ())
21
+ .build().makeExecutableSchema()
22
+ val gql = GraphQL .newGraphQL(schema).build()
23
+ val result = gql.execute(ExecutionInput .newExecutionInput().query(" query { places1 { id } places2 { id } }" ).build())
24
+ assert (result.getData<Map <String , List <* >>>()[" places1" ]?.size == 3 )
25
+ assert (result.getData<Map <String , List <* >>>()[" places2" ]?.size == 2 )
26
+ }
27
+
28
+ }
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ abstract class Review <T : Entity >(id : String? = null ) : Entity(id) {
4
+
5
+ val rating: Int? = null
6
+ val content: T ? = null
7
+
8
+ }
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ class Review1 (id : String? = null ) : Review<Place1>(id)
Original file line number Diff line number Diff line change
1
+ package graphql.kickstart.tools.place
2
+
3
+ class Review2 (id : String? = null ) : Review<Place2>(id)
Original file line number Diff line number Diff line change
1
+ type Query {
2
+ places1 : [Place1 ! ]
3
+ places2 : [Place2 ! ]
4
+ }
5
+
6
+ interface Entity {
7
+ id : ID !
8
+ }
9
+
10
+ interface Place {
11
+ name : String
12
+ reviews : [Review ! ]
13
+ }
14
+
15
+ interface OtherPlace {
16
+ name : String
17
+ other : String
18
+ reviews : [Review ! ]
19
+ }
20
+
21
+ type Place1 implements Entity , Place , OtherPlace {
22
+ id : ID !
23
+ name : String
24
+ other : String
25
+ reviews : [Review1 ! ]
26
+ }
27
+
28
+ type Place2 implements Entity , Place , OtherPlace {
29
+ id : ID !
30
+ name : String
31
+ other : String
32
+ reviews : [Review2 ! ]
33
+ }
34
+
35
+ interface Review {
36
+ id : ID !
37
+ rating : Int
38
+ content : Entity
39
+ }
40
+
41
+ type Review1 implements Review {
42
+ id : ID !
43
+ rating : Int
44
+ content : Place1
45
+ }
46
+
47
+ type Review2 implements Review {
48
+ id : ID !
49
+ rating : Int
50
+ content : Place2
51
+ }
You can’t perform that action at this time.
0 commit comments