aPureBase / KGraphQL

Pure Kotlin GraphQL implementation
https://kgraphql.io
MIT License
301 stars 58 forks source link

Access to parent execution results #130

Open jeggy opened 3 years ago

jeggy commented 3 years ago

It would be great to have a way to see all the previous results within our resolver of the execution tree.

This could be something like this:

// These types should be coming from KGraphQL
data class ExecutionResult(val node: SelectionNode.FieldNode, val value: Any)
@NotIntrospected data class ExecutionResults(val previousResults: List<ExecutionResult>)

..

property<String>("myValue") {
  resolver { myType, results: ExecutionResults ->
    val grandparent = results.firstOrNull { it.node.name.value == "grandParent" } as GrandParentType

    "This is a grand child of ${grandparent.name}"
  }
}