graphql.nadel.engine.transform.partition.NadelPartitionListMerger.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadel Show documentation
Show all versions of nadel Show documentation
Nadel is a Java library that combines multiple GrahpQL services together into one API.
package graphql.nadel.engine.transform.partition
import graphql.nadel.engine.transform.result.NadelResultInstruction
import graphql.nadel.engine.transform.result.json.JsonNode
import graphql.nadel.engine.util.unwrapNonNull
import graphql.normalized.ExecutableNormalizedField
import graphql.schema.GraphQLList
import graphql.schema.GraphQLObjectType
import graphql.schema.GraphQLOutputType
import graphql.schema.GraphQLScalarType
internal object NadelPartitionListMerger {
fun mergeDataFromList(
dataFromPartitionCalls: List,
thisNodesData: Any?,
parentNode: JsonNode,
overallField: ExecutableNormalizedField,
): List {
val listDataFromPartitionCalls = dataFromPartitionCalls
.flatMap {
if (it == null) {
emptyList()
} else {
it as List<*>
}
}
val thisNodesDataCast = thisNodesData?.let {
it as List<*>
} ?: emptyList()
return listOf(
NadelResultInstruction.Set(
subject = parentNode,
newValue = JsonNode(thisNodesDataCast + listDataFromPartitionCalls),
field = overallField
)
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy