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

Implement a DataLoaderDSL for batching #59

Open
@jeggy

Description

@jeggy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions