override fun toValue()

in graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/client/codegen/NullableInputValueSerializer.kt [29:52]


    override fun toValue(input: Any?): Value<*> {
        if (input == null) {
            return NullValue.newNullValue().build()
        }

        val optionalValue = getOptionalValue(input)

        if (optionalValue.isPresent) {
            return optionalValue.get()
        }

        val classes = (sequenceOf(input::class) + input::class.allSuperclasses.asSequence()) - Any::class
        val propertyValues = getPropertyValues(classes, input)

        val objectFields =
            propertyValues
                .asSequence()
                .map { (name, value) -> ObjectField(name, toValue(value)) }
                .toList()
        return ObjectValue
            .newObjectValue()
            .objectFields(objectFields)
            .build()
    }