Giter VIP home page Giter VIP logo

Comments (5)

Inego avatar Inego commented on June 3, 2024

Wouldn't this fix be a breaking change?

from java-dataloader.

Inego avatar Inego commented on June 3, 2024

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.

Inego avatar Inego commented on June 3, 2024

An example: Inego@1c18495

from java-dataloader.

Inego avatar Inego commented on June 3, 2024

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.

bbakerman avatar bbakerman commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.