Comments (5)
Wouldn't this fix be a breaking change?
from java-dataloader.
A non-breaking enhancement would be to add an optional field dataLoaderFactory
to the DataLoaderRegistry
.
This data loader factory, if set, would then be used in the getDataLoader
function to act as the supplier of the required data loaders "on the fly" in case there is no such dataloader yet.
In the simplest, just a map of possible DL keys and their corresponding suppliers could serve as such factory.
from java-dataloader.
An example: Inego@1c18495
from java-dataloader.
In fact, there's a simpler/cleaner solution without an overhead for those who need this lazy behavior:
master...Inego:lazy-dl-registry
The usage would be as simple as:
// Prepare the singleton factory once...
LazyDataLoaderFactory factory = new LazyDataLoaderFactory();
factory.register("clients", () -> new ClientDataLoader());
factory.register("products", () -> new ProductDataLoader());
// ... and create a lazy registry for every request
LazyDataLoaderRegistry registry = factory.createRegistry();
from java-dataloader.
I looked into this and its really kinda pointless.
We can make it lazy but as soon as you called dispatchAll
the it needs to materialise the dataloaders and dispatch them
We would have to write a fancy MemoizingSupplierWithTracking that could decide if its every been asked for and then filter them out from the list. In short I am not sure that its worth it.
I would love to see more evidence now of the costs of creating a DL even if its not needed in a certain graphql request.
from java-dataloader.
Related Issues (20)
- invalid automatic module name when used with Java modules
- Version 3.0.0 and later is no OSGi bundle anymore HOT 2
- Automatic Module Name clashes with graphql-java Module HOT 2
- Add ReactiveStreams and Kotlin Coroutines variants for DataLoader HOT 1
- Support Flow or Channel as Subscription return type HOT 1
- Failed to build.gradle HOT 1
- Querying for length of dataloader queue HOT 2
- Avoid allocations when dataloader has no work
- ScheduledDataLoaderRegistry.newScheduledRegistry() creates new ScheduledExecutorService on every invocation
- ScheduledDataLoaderRegistry can leak scheduler threads HOT 1
- When dispatchPredicate condition evaluates to false, shouldDispatch should return false HOT 3
- License question HOT 4
- the `synchronized` in DataLoader
- How to wrap Caffeine with CacheMap? HOT 6
- Is the data loader's per-key context allowed to be null?
- Java DataLoader: Mismatches results HOT 1
- Null pointer in dispatchQueueBatch v2.1.1 HOT 1
- ValueCache: batch function isn't always triggered on cache miss HOT 5
- DataLoader 3.x will not be upgraded in graphql-java 17.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-dataloader.