Open
Description
Currently if I want to get access to the context within a dataLoader resolver I need to do the following:
dataProperty<Pair<Int, Int>, List<Value>>("valueList") {
prepare { parent, ctx: Context -> ctx.userId to parent.id }
loader { keys ->
val dataMap: Map<Int, List<Value>> = loadValues(keys.first().first, keys.map { it.second })
keys.map { ExecutionResult.Success(dataMap.getValue(it.second)) }
}
}
It would be great if I didn't need to pass anything from the context from the prepare to the loader, so it could look more like something this:
dataProperty<Int, List<Value>>("valueList") {
prepare { it.id }
loader { parentIds: List<Int>, ctx: Context ->
val dataMap: Map<Int, List<Value>> = loadValues(ctx.userId, parentIds)
keys.map { ExecutionResult.Success(dataMap.getValue(it)) }
}
}