Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Implement a DataLoaderDSL for batching #59

Open
jeggy opened this issue Feb 11, 2019 · 0 comments
Open

Implement a DataLoaderDSL for batching #59

jeggy opened this issue Feb 11, 2019 · 0 comments

Comments

@jeggy
Copy link
Contributor

jeggy commented Feb 11, 2019

Implement DataLoader style.

I've been thinking about a structure like this:

...
data class Tree(val id: String, val parentId: String?)
...
type<Tree> {
    // String - defines the key that will be sent from the [prepare] into [loader]
    // List<Tree> - defines the return type that the [loader] is required to return.
    // the loader is then required to return it in a map format like Map<String, List<Tree>>
    dataProperty<String, List<Tree>>("children") {
        // Step 2: This will only be called once.
        loader { keys: List<String> ->
            keys.map{ id -> id to listOf(Tree("SomeId", id)) }.toMap()
        }
    
        // Step 1: This will be called for each node in the list, or only once if it's not a list
        prepare { parent: Tree -> parent.id }
    }
}

Anyone is welcome with some input on how this could be achieved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant