Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0a27e76
introducing of a special CompletableFuture enabling scheduling of nes…
andimarek Mar 30, 2025
f655893
replace countdown latch with an async solution
andimarek Mar 30, 2025
3675d8a
wip
andimarek Mar 30, 2025
c2d0676
refactor
andimarek Mar 31, 2025
36b2d64
refactor
andimarek Mar 31, 2025
eb8f9bb
naming
andimarek Mar 31, 2025
d1df820
comment
andimarek Mar 31, 2025
2c5da50
fix test
andimarek Mar 31, 2025
62325eb
green tests without any chain
andimarek Apr 1, 2025
89f2c48
cleanup
andimarek Apr 1, 2025
67df3a9
use ResultPath to identify a field instead DFE
andimarek Apr 1, 2025
dc8ac9a
fix a bug in the PerLevel dispatcher regarding which level to dispatch
andimarek Apr 1, 2025
3be8443
fix test
andimarek Apr 1, 2025
0686385
don't put ExecutionStrategy into context
andimarek Apr 1, 2025
bcfeff8
introduce toInternal method in DFE
andimarek Apr 1, 2025
bf0b730
Merge branch 'master' into dataloader-cfs
andimarek Apr 2, 2025
89b8c13
use new DataLoaderDelegate
andimarek Apr 2, 2025
6d02760
Merge branch 'master' into dataloader-cfs
andimarek Apr 4, 2025
5e00964
update dataloader
andimarek Apr 4, 2025
ce4d3f6
make batch window configurable and make one test more stable
andimarek Apr 4, 2025
401d09d
scheduled executor can be configured for delayed dispatching
andimarek Apr 4, 2025
2a29686
new handling of Dataloders can be disabled
andimarek Apr 4, 2025
e08ca66
Merge branch 'master' into dataloader-cfs
andimarek Apr 7, 2025
42d1d1d
more stuff
andimarek Apr 7, 2025
24d4687
Merge branch 'master' into dataloader-cfs
andimarek Apr 7, 2025
51efbfc
fix mutations with DataLoader
andimarek Apr 7, 2025
6e0da52
testing and cleanup
andimarek Apr 7, 2025
12fe329
green tests
andimarek Apr 8, 2025
e3539c7
disable new chaining algo by default
andimarek Apr 8, 2025
2369db5
cleanup
andimarek Apr 8, 2025
861a317
cleanup
andimarek Apr 8, 2025
1f4d18e
some performance,naming,cleanup, docs
andimarek Apr 9, 2025
efa8fb0
fix an engine state edge case
andimarek Apr 10, 2025
f70630d
fix an engine state edge case
andimarek Apr 10, 2025
e759137
change list implementation
andimarek Apr 10, 2025
c20ed90
Merge branch 'master' into dataloader-cfs
andimarek Apr 11, 2025
bcfb9ef
fix dispatching edge case
andimarek Apr 11, 2025
572fbdf
data loader performance test with chaining on
andimarek Apr 11, 2025
6c3d14c
data loader performance test with chaining on
andimarek Apr 11, 2025
ee1541d
make result path to String faster
andimarek Apr 14, 2025
0d76d31
Merge branch 'master' into dataloader-cfs
andimarek Apr 15, 2025
47300cb
fix merge problem
andimarek Apr 15, 2025
fed7456
Merge branch 'master' into dataloader-cfs
andimarek May 1, 2025
d57d4fd
naming
andimarek May 1, 2025
34bc3d7
add helper methods to configure new dispatching strategy
andimarek May 1, 2025
604f679
implement toInternal by default
andimarek May 1, 2025
6328062
formatting
andimarek May 1, 2025
65cc42a
cleanup
andimarek May 1, 2025
51f9344
cleanup
andimarek May 2, 2025
d1384e1
cleanup
andimarek May 2, 2025
5b04714
cleanup
andimarek May 2, 2025
a622d0d
PR feedback
andimarek May 2, 2025
cdb335f
PR feedback
andimarek May 2, 2025
81c4b09
PR feedback
andimarek May 2, 2025
4e0c26a
Merge branch 'master' into dataloader-cfs
andimarek May 16, 2025
c9a3ff3
merging
andimarek May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add helper methods to configure new dispatching strategy
  • Loading branch information
andimarek committed May 1, 2025
commit 34bc3d7f0533c74196cfeb76c6df3331c13a9a32
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@


import graphql.ExperimentalApi;
import graphql.GraphQLContext;
import org.jspecify.annotations.NullMarked;

/**
* GraphQLContext keys related to DataLoader dispatching.
*/
@ExperimentalApi
@NullMarked
public final class DataLoaderDispatchingContextKeys {
Expand Down Expand Up @@ -39,4 +43,39 @@ private DataLoaderDispatchingContextKeys() {
* Expects a boolean value.
*/
public static final String ENABLE_DATA_LOADER_CHAINING = "__GJ_enable_data_loader_chaining";


/**
* Enables the ability that chained DataLoaders are dispatched automatically.
*
* @param graphQLContext
*/
public static void enableDataLoaderChaining(GraphQLContext graphQLContext) {
Comment thread
andimarek marked this conversation as resolved.
Outdated
graphQLContext.put(ENABLE_DATA_LOADER_CHAINING, true);
}


/**
* Sets in nanoseconds the batch window size for delayed DataLoaders.
* That is for DataLoaders, that are not batched as part of the normal per level
* dispatching, because they were created after the level was already dispatched.
*
* @param graphQLContext
* @param batchWindowSizeNanoSeconds
*/
public static void setDelayedDataLoaderBatchWindowSizeNanoSeconds(GraphQLContext graphQLContext, long batchWindowSizeNanoSeconds) {
Comment thread
andimarek marked this conversation as resolved.
Outdated
graphQLContext.put(DELAYED_DATA_LOADER_BATCH_WINDOW_SIZE_NANO_SECONDS, batchWindowSizeNanoSeconds);
}

/**
* Sets the instance of {@link DelayedDataLoaderDispatcherExecutorFactory} that is used to create the
* {@link java.util.concurrent.ScheduledExecutorService} for the delayed DataLoader dispatching.
* <p>
*
* @param graphQLContext
* @param delayedDataLoaderDispatcherExecutorFactory
*/
public static void setDelayedDataLoaderDispatchingExecutorFactory(GraphQLContext graphQLContext, DelayedDataLoaderDispatcherExecutorFactory delayedDataLoaderDispatcherExecutorFactory) {
graphQLContext.put(DELAYED_DATA_LOADER_DISPATCHING_EXECUTOR_FACTORY, delayedDataLoaderDispatcherExecutorFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import java.util.concurrent.ScheduledExecutorService;

/**
* See {@link DataLoaderDispatchingContextKeys} for how to set it.
*/
@ExperimentalApi
@NullMarked
@FunctionalInterface
Expand Down
11 changes: 6 additions & 5 deletions src/test/groovy/graphql/ChainedDataLoaderTest.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package graphql

import graphql.execution.ExecutionId
import graphql.execution.instrumentation.dataloader.DelayedDataLoaderDispatcherExecutorFactory
import graphql.execution.instrumentation.dataloader.DataLoaderDispatchingContextKeys
import graphql.execution.instrumentation.dataloader.DelayedDataLoaderDispatcherExecutorFactory
import graphql.schema.DataFetcher
import org.awaitility.Awaitility
import org.dataloader.BatchLoader
Expand Down Expand Up @@ -72,7 +72,8 @@ class ChainedDataLoaderTest extends Specification {
def graphQL = GraphQL.newGraphQL(schema).build()

def query = "{ dogName catName } "
def ei = newExecutionInput(query).graphQLContext([(DataLoaderDispatchingContextKeys.ENABLE_DATA_LOADER_CHAINING): true]).dataLoaderRegistry(dataLoaderRegistry).build()
def ei = newExecutionInput(query).dataLoaderRegistry(dataLoaderRegistry).build()
DataLoaderDispatchingContextKeys.enableDataLoaderChaining(ei.graphQLContext)

when:
def efCF = graphQL.executeAsync(ei)
Expand Down Expand Up @@ -383,8 +384,8 @@ class ChainedDataLoaderTest extends Specification {
def query = "{ foo bar } "
def ei = newExecutionInput(query).graphQLContext([(DataLoaderDispatchingContextKeys.ENABLE_DATA_LOADER_CHAINING): true]).dataLoaderRegistry(dataLoaderRegistry).build()

// make the window to 50ms
ei.getGraphQLContext().put(DataLoaderDispatchingContextKeys.DELAYED_DATA_LOADER_BATCH_WINDOW_SIZE_NANO_SECONDS, 1_000_000L * 250)
// make the window 250ms
DataLoaderDispatchingContextKeys.setDelayedDataLoaderBatchWindowSizeNanoSeconds(ei.graphQLContext, 1_000_000L * 250)

when:
def efCF = graphQL.executeAsync(ei)
Expand Down Expand Up @@ -435,7 +436,7 @@ class ChainedDataLoaderTest extends Specification {


ScheduledExecutorService scheduledExecutorService = Mock()
ei.getGraphQLContext().put(DataLoaderDispatchingContextKeys.DELAYED_DATA_LOADER_DISPATCHING_EXECUTOR_FACTORY, new DelayedDataLoaderDispatcherExecutorFactory() {
DataLoaderDispatchingContextKeys.setDelayedDataLoaderDispatchingExecutorFactory(ei.getGraphQLContext(), new DelayedDataLoaderDispatcherExecutorFactory() {
@Override
ScheduledExecutorService createExecutor(ExecutionId executionId, GraphQLContext graphQLContext) {
return scheduledExecutorService
Expand Down