graphql.nadel.engine.transform.hydration.NadelHydrationFieldsBuilder.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.hydration
import graphql.nadel.Service
import graphql.nadel.engine.blueprint.NadelBatchHydrationFieldInstruction
import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction
import graphql.nadel.engine.blueprint.NadelHydrationFieldInstruction
import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint
import graphql.nadel.engine.blueprint.hydration.NadelHydrationActorInputDef
import graphql.nadel.engine.transform.GraphQLObjectTypeName
import graphql.nadel.engine.transform.artificial.NadelAliasHelper
import graphql.nadel.engine.transform.hydration.batch.NadelBatchHydrationInputBuilder
import graphql.nadel.engine.transform.hydration.batch.NadelBatchHydrationObjectIdFieldBuilder.makeObjectIdFields
import graphql.nadel.engine.transform.query.NFUtil
import graphql.nadel.engine.transform.result.json.JsonNode
import graphql.nadel.engine.util.deepClone
import graphql.nadel.engine.util.resolveObjectTypes
import graphql.nadel.engine.util.toBuilder
import graphql.nadel.engine.util.unwrapAll
import graphql.nadel.hooks.NadelExecutionHooks
import graphql.normalized.ExecutableNormalizedField
import graphql.normalized.NormalizedInputValue
internal object NadelHydrationFieldsBuilder {
fun makeActorQueries(
instruction: NadelHydrationFieldInstruction,
aliasHelper: NadelAliasHelper,
fieldToHydrate: ExecutableNormalizedField,
parentNode: JsonNode,
executionBlueprint: NadelOverallExecutionBlueprint,
): List {
return NadelHydrationInputBuilder.getInputValues(
instruction = instruction,
aliasHelper = aliasHelper,
fieldToHydrate = fieldToHydrate,
parentNode = parentNode,
).map { args ->
makeActorQueries(
instruction = instruction,
fieldArguments = args,
fieldChildren = deepClone(fields = fieldToHydrate.children),
executionBlueprint = executionBlueprint,
)
}
}
fun makeBatchActorQueries(
executionBlueprint: NadelOverallExecutionBlueprint,
instruction: NadelBatchHydrationFieldInstruction,
aliasHelper: NadelAliasHelper,
hydratedField: ExecutableNormalizedField,
parentNodes: List,
hooks: NadelExecutionHooks,
userContext: Any?,
): List {
val argBatches = NadelBatchHydrationInputBuilder.getInputValueBatches(
instruction = instruction,
aliasHelper = aliasHelper,
hydrationField = hydratedField,
parentNodes = parentNodes,
hooks = hooks,
userContext = userContext,
)
return makeBatchActorQueries(
executionBlueprint = executionBlueprint,
instruction = instruction,
aliasHelper = aliasHelper,
hydratedField = hydratedField,
argBatches = argBatches,
)
}
fun makeBatchActorQueries(
executionBlueprint: NadelOverallExecutionBlueprint,
instruction: NadelBatchHydrationFieldInstruction,
aliasHelper: NadelAliasHelper,
hydratedField: ExecutableNormalizedField,
argBatches: List