Skip to content

Commit 37980a0

Browse files
WIP: Notes after pairing with Andi
1 parent ea8a89f commit 37980a0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/graphql/execution/instrumentation/dataloader/PerLevelDataLoaderDispatchStrategyWithDefer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,31 @@
1818

1919
@Internal
2020
public class PerLevelDataLoaderDispatchStrategyWithDefer implements DataLoaderDispatchStrategy {
21+
// ITERATIONS:
22+
// 1 - all defer fields should be ignored.
23+
// 2 - new call stacks for every defer block.
2124

2225
private final CallStack callStack;
2326
private final ExecutionContext executionContext;
2427

28+
// data fetchers state: 1) not called 2) called but not returned 3) called and resolve
29+
30+
// TODO: add test for only a scalar being deferred
2531

2632
private static class CallStack {
2733

2834
private final LockKit.ReentrantLock lock = new LockKit.ReentrantLock();
35+
36+
// expected data fetchers method invocations
2937
private final LevelMap expectedFetchCountPerLevel = new LevelMap();
38+
// actual data fetchers that were invoked and returned
3039
private final LevelMap fetchCountPerLevel = new LevelMap();
40+
41+
// object stuff
3142
private final LevelMap expectedStrategyCallsPerLevel = new LevelMap();
3243
private final LevelMap happenedStrategyCallsPerLevel = new LevelMap();
44+
45+
// data fetchers methods have returned (returned an actual value, which we can inspect - it is list, non-null, object, etc....)
3346
private final LevelMap happenedOnFieldValueCallsPerLevel = new LevelMap();
3447

3548
private final LevelMap expectedDeferredStrategyCallsPerLevel = new LevelMap();

src/test/groovy/graphql/execution/instrumentation/dataloader/DeferWithDataLoaderTest.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ class DeferWithDataLoaderTest extends Specification {
217217
name
218218
}
219219
}
220-
... @defer(if: true) {
220+
... @defer {
221221
expensiveShops {
222-
name
222+
departments {
223+
name
224+
}
223225
}
224226
}
225227
}

0 commit comments

Comments
 (0)