Skip to content

Commit 1bc8bc9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 296-ast-printer-support
# Conflicts: # src/main/java/graphql/introspection/Introspection.java
2 parents cc1aab6 + cb7917d commit 1bc8bc9

20 files changed

Lines changed: 373 additions & 424 deletions

‎src/main/java/graphql/GraphQL.java‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ public class GraphQL {
3232

3333
private static final Logger log = LoggerFactory.getLogger(GraphQL.class);
3434

35-
private static final ExecutionIdProvider DEFAULT_EXECUTION_ID_PROVIDER = new ExecutionIdProvider() {
36-
@Override
37-
public ExecutionId provide(String query, String operationName, Object context) {
38-
return ExecutionId.generate();
39-
}
40-
};
35+
private static final ExecutionIdProvider DEFAULT_EXECUTION_ID_PROVIDER = (query, operationName, context) -> ExecutionId.generate();
4136

4237
private final GraphQLSchema graphQLSchema;
4338
private final ExecutionStrategy queryStrategy;

‎src/main/java/graphql/execution/ExecutorServiceExecutionStrategy.java‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ public ExecutionResult execute(final ExecutionContext executionContext, final Ex
4545
Map<String, Future<ExecutionResult>> futures = new LinkedHashMap<>();
4646
for (String fieldName : fields.keySet()) {
4747
final List<Field> fieldList = fields.get(fieldName);
48-
Callable<ExecutionResult> resolveField = new Callable<ExecutionResult>() {
49-
@Override
50-
public ExecutionResult call() throws Exception {
51-
return resolveField(executionContext, parameters, fieldList);
52-
53-
}
54-
};
48+
Callable<ExecutionResult> resolveField = () -> resolveField(executionContext, parameters, fieldList);
5549
futures.put(fieldName, executorService.submit(resolveField));
5650
}
5751
try {

‎src/main/java/graphql/execution/batched/BatchedDataFetcherFactory.java‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ public BatchedDataFetcher create(final DataFetcher supplied) {
2323
Method getMethod = supplied.getClass().getMethod("get", DataFetchingEnvironment.class);
2424
Batched batched = getMethod.getAnnotation(Batched.class);
2525
if (batched != null) {
26-
return new BatchedDataFetcher() {
27-
@Override
28-
public Object get(DataFetchingEnvironment environment) {
29-
return supplied.get(environment);
30-
}
31-
};
26+
return (BatchedDataFetcher) supplied::get;
3227
}
3328
} catch (NoSuchMethodException e) {
3429
throw new IllegalArgumentException(e);

‎src/main/java/graphql/introspection/Introspection.java‎

Lines changed: 122 additions & 200 deletions
Large diffs are not rendered by default.

‎src/main/java/graphql/relay/Connection.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
/**
66
* represents a connection in relay.
77
*/
8-
public interface Connection {
8+
public interface Connection<T> {
99

10-
List<Edge> getEdges();
10+
List<Edge<T>> getEdges();
1111

1212
PageInfo getPageInfo();
1313

‎src/main/java/graphql/relay/ConnectionCursor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package graphql.relay;
22

33
/**
4-
* represents a connection cursor in relay.
4+
* represents a {@link Connection connection} cursor in relay.
55
*/
66
public interface ConnectionCursor {
77

‎src/main/java/graphql/relay/DefaultConnection.java‎

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
11
package graphql.relay;
22

33
import java.util.ArrayList;
4+
import java.util.Collections;
45
import java.util.List;
56

6-
public class DefaultConnection implements Connection {
7+
public class DefaultConnection<T> implements Connection<T> {
78

8-
private List<Edge> edges = new ArrayList<>();
9+
private List<Edge<T>> edges = new ArrayList<>();
910

1011
private PageInfo pageInfo;
1112

13+
/**
14+
* @deprecated prefer {@link #DefaultConnection(List, PageInfo)}
15+
*/
16+
@Deprecated
17+
public DefaultConnection() {
18+
}
19+
20+
/**
21+
* @param edges edges
22+
* @param pageInfo page info
23+
* @throws IllegalArgumentException if edges or page info is null. use {@link Collections#emptyList()} for empty edges.
24+
*/
25+
public DefaultConnection(List<Edge<T>> edges, PageInfo pageInfo) {
26+
if (edges == null) {
27+
throw new IllegalArgumentException("edges cannot be empty");
28+
}
29+
if (pageInfo == null) {
30+
throw new IllegalArgumentException("page info cannot be null");
31+
}
32+
// TODO make defensive copy
33+
this.edges = edges;
34+
this.pageInfo = pageInfo;
35+
}
36+
1237
@Override
13-
public List<Edge> getEdges() {
14-
return edges;
38+
public List<Edge<T>> getEdges() {
39+
return Collections.unmodifiableList(edges);
1540
}
1641

17-
public void setEdges(List<Edge> edges) {
42+
/**
43+
* @deprecated prefer {@link #DefaultConnection(List, PageInfo)} and avoid mutation
44+
*/
45+
@Deprecated
46+
public void setEdges(List<Edge<T>> edges) {
47+
if (edges == null) { // TODO remove setter
48+
edges = Collections.emptyList();
49+
}
1850
this.edges = edges;
1951
}
2052

@@ -23,6 +55,10 @@ public PageInfo getPageInfo() {
2355
return pageInfo;
2456
}
2557

58+
/**
59+
* @deprecated prefer {@link #DefaultConnection(List, PageInfo)} and avoid mutation
60+
*/
61+
@Deprecated
2662
public void setPageInfo(PageInfo pageInfo) {
2763
this.pageInfo = pageInfo;
2864
}

‎src/main/java/graphql/relay/DefaultEdge.java‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
package graphql.relay;
22

3-
public class DefaultEdge implements Edge {
4-
5-
public DefaultEdge(Object node, DefaultConnectionCursor cursor) {
3+
public class DefaultEdge<T> implements Edge<T> {
4+
5+
public DefaultEdge(T node, ConnectionCursor cursor) {
6+
if (node == null) {
7+
throw new IllegalArgumentException("node cannot be null");
8+
}
9+
if (cursor == null) {
10+
throw new IllegalArgumentException("cursor cannot be null");
11+
}
612
this.node = node;
713
this.cursor = cursor;
814
}
915

10-
private Object node;
16+
/**
17+
* @deprecated prefer {@link #DefaultEdge(Object, ConnectionCursor)}
18+
*/
19+
@Deprecated
20+
public DefaultEdge() {
21+
}
22+
23+
private T node;
1124
private ConnectionCursor cursor;
1225

1326
@Override
14-
public Object getNode() {
27+
public T getNode() {
1528
return node;
1629
}
1730

18-
public void setNode(Object node) {
31+
/**
32+
* @deprecated prefer {@link #DefaultEdge(Object, ConnectionCursor)} and avoid mutation.
33+
*/
34+
@Deprecated
35+
public void setNode(T node) {
1936
this.node = node;
2037
}
2138

@@ -24,6 +41,10 @@ public ConnectionCursor getCursor() {
2441
return cursor;
2542
}
2643

44+
/**
45+
* @deprecated prefer {@link #DefaultEdge(Object, ConnectionCursor)} and avoid mutation.
46+
*/
47+
@Deprecated
2748
public void setCursor(ConnectionCursor cursor) {
2849
this.cursor = cursor;
2950
}

‎src/main/java/graphql/relay/DefaultPageInfo.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,29 @@ public class DefaultPageInfo implements PageInfo {
77
private boolean hasPreviousPage;
88
private boolean hasNextPage;
99

10+
/**
11+
* @deprecated prefer {@link #DefaultPageInfo(ConnectionCursor, ConnectionCursor, boolean, boolean)}
12+
*/
13+
@Deprecated
14+
public DefaultPageInfo() {
15+
}
16+
17+
public DefaultPageInfo(ConnectionCursor startCursor, ConnectionCursor endCursor, boolean hasPreviousPage, boolean hasNextPage) {
18+
this.startCursor = startCursor;
19+
this.endCursor = endCursor;
20+
this.hasPreviousPage = hasPreviousPage;
21+
this.hasNextPage = hasNextPage;
22+
}
23+
1024
@Override
1125
public ConnectionCursor getStartCursor() {
1226
return startCursor;
1327
}
1428

29+
/**
30+
* @deprecated prefer {@link #DefaultPageInfo(ConnectionCursor, ConnectionCursor, boolean, boolean)} and avoid mutation
31+
*/
32+
@Deprecated
1533
public void setStartCursor(ConnectionCursor startCursor) {
1634
this.startCursor = startCursor;
1735
}
@@ -21,6 +39,10 @@ public ConnectionCursor getEndCursor() {
2139
return endCursor;
2240
}
2341

42+
/**
43+
* @deprecated prefer {@link #DefaultPageInfo(ConnectionCursor, ConnectionCursor, boolean, boolean)} and avoid mutation
44+
*/
45+
@Deprecated
2446
public void setEndCursor(ConnectionCursor endCursor) {
2547
this.endCursor = endCursor;
2648
}
@@ -30,6 +52,10 @@ public boolean isHasPreviousPage() {
3052
return hasPreviousPage;
3153
}
3254

55+
/**
56+
* @deprecated prefer {@link #DefaultPageInfo(ConnectionCursor, ConnectionCursor, boolean, boolean)} and avoid mutation
57+
*/
58+
@Deprecated
3359
public void setHasPreviousPage(boolean hasPreviousPage) {
3460
this.hasPreviousPage = hasPreviousPage;
3561
}
@@ -39,6 +65,10 @@ public boolean isHasNextPage() {
3965
return hasNextPage;
4066
}
4167

68+
/**
69+
* @deprecated prefer {@link #DefaultPageInfo(ConnectionCursor, ConnectionCursor, boolean, boolean)}
70+
*/
71+
@Deprecated
4272
public void setHasNextPage(boolean hasNextPage) {
4373
this.hasNextPage = hasNextPage;
4474
}

‎src/main/java/graphql/relay/Edge.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/**
44
* represents an edge in relay.
55
*/
6-
public interface Edge {
6+
public interface Edge<T> {
77

8-
Object getNode();
8+
T getNode();
99

1010
ConnectionCursor getCursor();
1111

0 commit comments

Comments
 (0)