Skip to content

Commit 88161f5

Browse files
committed
Simple connection extends connection because we need to return "Connection"
object (The irrelevant methods throw appropriate exception)
1 parent 2a3f280 commit 88161f5

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

src/main/java/graphql/annotations/connection/simple/SimpleConnection.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package graphql.annotations.connection.simple;
22

3+
4+
import graphql.relay.Connection;
5+
36
import java.util.List;
47

58
/**
@@ -8,7 +11,7 @@
811
*
912
* @param <T> The type of the entities
1013
*/
11-
public interface SimpleConnection<T> {
14+
public interface SimpleConnection<T> extends Connection<T> {
1215

1316
/**
1417
* Get the list of the entities
@@ -22,5 +25,5 @@ public interface SimpleConnection<T> {
2225
*
2326
* @return The amount of entities
2427
*/
25-
long getOverAllCount();
28+
long getTotalCount();
2629
}

src/main/java/graphql/annotations/connection/simple/SimpleConnectionDataFetcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.annotations.connection.simple;
22

3+
import graphql.relay.Connection;
34
import graphql.schema.DataFetcher;
45
import graphql.schema.DataFetchingEnvironment;
56

@@ -29,7 +30,7 @@ public SimpleConnectionDataFetcher(Class<? extends SimpleConnectionFetcher<T>> c
2930
}
3031

3132
@Override
32-
public SimpleConnection<T> get(DataFetchingEnvironment environment) {
33+
public Connection<T> get(DataFetchingEnvironment environment) {
3334
SimpleConnectionFetcher<T> conn = constructNewInstance(constructor, actualDataFetcher);
3435
return conn.get(environment);
3536
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package graphql.annotations.connection.simple;
22

3-
import graphql.schema.DataFetcher;
3+
import graphql.annotations.connection.ConnectionFetcher;
44

5-
public interface SimpleConnectionFetcher<T> extends DataFetcher<SimpleConnection<T>> {
5+
public interface SimpleConnectionFetcher<T> extends ConnectionFetcher<T> {
66
}
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
package graphql.annotations.connection.simple;
22

3+
import graphql.relay.Edge;
4+
import graphql.relay.PageInfo;
5+
6+
import java.util.List;
7+
38
public class SimplePaginatedDataImpl<T> extends AbstractSimplePaginatedData<T> {
49

5-
private long overAllCount;
10+
private long totalCount;
611

7-
public SimplePaginatedDataImpl(Iterable<T> data, long overAllCount) {
12+
public SimplePaginatedDataImpl(Iterable<T> data, long totalCount) {
813
super(data);
9-
this.overAllCount = overAllCount;
14+
this.totalCount = totalCount;
15+
}
16+
17+
@Override
18+
public long getTotalCount() {
19+
return totalCount;
20+
}
21+
22+
@Override
23+
public List<Edge<T>> getEdges() {
24+
throw new UnsupportedOperationException("Simple paging doesn't have edges");
1025
}
1126

1227
@Override
13-
public long getOverAllCount() {
14-
return overAllCount;
28+
public PageInfo getPageInfo() {
29+
throw new UnsupportedOperationException("Simple paging doesn't have page info");
1530
}
1631
}

0 commit comments

Comments
 (0)