Skip to content

Commit c3ae0b3

Browse files
committed
Merge branch 'master' into bugfix/114
# Conflicts: # pom.xml # src/main/kotlin/com/coxautodev/graphql/tools/FieldResolverScanner.kt # src/test/groovy/com/coxautodev/graphql/tools/RelayConnectionSpec.groovy
2 parents 4e9ed00 + 18eec21 commit c3ae0b3

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

src/main/kotlin/com/coxautodev/graphql/tools/SchemaObjects.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.coxautodev.graphql.tools
33
import graphql.schema.GraphQLObjectType
44
import graphql.schema.GraphQLSchema
55
import graphql.schema.GraphQLType
6+
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility
67

78
/**
89
* @author Andrew Potter
@@ -17,6 +18,7 @@ data class SchemaObjects(val query: GraphQLObjectType, val mutation: GraphQLObje
1718
.mutation(mutation)
1819
.subscription(subscription)
1920
.additionalTypes(dictionary)
21+
// .fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY)
2022
.build()
2123

2224
/**
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.coxautodev.graphql.tools;
2+
3+
import graphql.relay.*;
4+
import graphql.schema.DataFetchingEnvironment;
5+
import org.junit.Test;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
import java.util.stream.Collectors;
10+
11+
public class RelayConnectionTest {
12+
13+
@Test
14+
public void compiles() {
15+
SchemaParser.newParser().file("RelayConnection.graphqls")
16+
.resolvers(new QueryResolver())
17+
.dictionary(User.class)
18+
.build()
19+
.makeExecutableSchema();
20+
}
21+
22+
static class QueryResolver implements GraphQLQueryResolver {
23+
// fixme #114: desired return type to use: Connection<User>
24+
public UserConnection users(int first, String after, DataFetchingEnvironment env) {
25+
return (UserConnection) new SimpleListConnection<User>(new ArrayList()).get(env);
26+
}
27+
}
28+
29+
// fixme #114: remove this implementation
30+
static class UserConnection extends DefaultConnection<User> {
31+
32+
UserConnection(List<Edge<User>> edges, PageInfo pageInfo) {
33+
super(edges, pageInfo);
34+
}
35+
36+
public List<UserEdge> edges() {
37+
return super.getEdges().stream()
38+
.map(UserEdge.class::cast)
39+
.collect(Collectors.toList());
40+
}
41+
42+
public PageInfo getPageInfo() {
43+
return super.getPageInfo();
44+
}
45+
}
46+
47+
// fixme #114: remove this implementation
48+
static class UserEdge extends DefaultEdge<User> {
49+
50+
UserEdge(User node, ConnectionCursor cursor) {
51+
super(node, cursor);
52+
}
53+
54+
}
55+
56+
static class User {
57+
Long id;
58+
String name;
59+
}
60+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
type Query {
2+
users(first: Int, after: String): UserConnection
3+
}
4+
5+
type UserConnection {
6+
edges: [UserEdge!]!
7+
pageInfo: PageInfo!
8+
}
9+
10+
type UserEdge {
11+
cursor: String!
12+
node: User!
13+
}
14+
15+
type User {
16+
id: ID!
17+
name: String
18+
}
19+
20+
type PageInfo {
21+
22+
}

0 commit comments

Comments
 (0)