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

graphql.nadel.engine.blueprint.hydration.NadelHydrationActorInputDef.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-11-20T03-31-21-302962b7
Show newest version
package graphql.nadel.engine.blueprint.hydration

import graphql.language.Value
import graphql.nadel.engine.transform.query.NadelQueryPath
import graphql.normalized.NormalizedInputValue
import graphql.schema.GraphQLArgument
import graphql.schema.GraphQLFieldDefinition

data class NadelHydrationActorInputDef(
    val name: String,
    val actorArgumentDef: GraphQLArgument,
    val valueSource: ValueSource,
) {
    sealed class ValueSource {
        /**
         * Uses a value from a field in the same object (or its children) as input e.g.
         *
         * ```graphql
         * type Issue {
         *   id: ID! # Value used as argument to issueId
         *   owner: User @hydrated(from: ["issueOwner"], args: [
         *      {name: "issueId" valueFromField: ["id"]}
         *   ])
         * }
         * ```
         */
        data class FieldResultValue(
            val queryPathToField: NadelQueryPath,
            val fieldDefinition: GraphQLFieldDefinition,
        ) : ValueSource()

        /**
         * Uses a value from a field in the same object (or its children) as input e.g.
         *
         * ```graphql
         * type Issue {
         *   secret(password: String): JSON @hydrated(from: ["issueSecret"], args: [
         *     {name: "password", valueFromArg: "password"}
         *   ])
         * }
         * ```
         */
        data class ArgumentValue(
            val argumentName: String,
            val argumentDefinition: GraphQLArgument,
            val defaultValue: NormalizedInputValue?,
        ) : ValueSource()

        /**
         * Represents a static argument value, which is hardcoded in the source code. e.g.
         *
         * ```graphql
         * type Issue {
         *   id: ID!
         *   owner: User @hydrated(from: ["issueOwner"], args: [
         *      {name: "issueId" value: "issue123"}
         *   ])
         * }
         * ```
         */
        data class StaticValue(
            val value: Value<*>,
        ) : ValueSource()
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy