All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.nadel.engine.transform.partition.NadelPartitionListMerger.kt Maven / Gradle / Ivy

Go to download

Nadel is a Java library that combines multiple GrahpQL services together into one API.

There is a newer version: 2024-12-10T04-34-06-f2ee9344
Show newest version
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