Skip to content

Make the DataLoader constructor protected to make it more customisable #47

@drupalspring

Description

@drupalspring

I would like to make the DataLoader to load the Key context in a type safe manner and in order to reuse the current infrastructure , I choose to extend the DataLoader :

public abstract class MyDataLoader<K, V, C> extends DataLoader<K, V> {

      public MyDataLoader(){
          super(newMappedBatchLoaderWithContext() , null); 
       }

       public CompletableFuture<V> loadWithKeyContext(K key, C keyContext) {
         return super.load(key, keyContext);
    }

      public abstract MappedBatchLoaderWithContext<K, V> newMappedBatchLoaderWithContext();
}

But the constructor DataLoader(Object batchLoadFunction, DataLoaderOptions options) in DataLoader are in the private scope now. Is it a good idea to make it be the protected scoped to provide more options for developers in case they want to customise their DataLoader?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions