graphql-kotlin
graphql-kotlin copied to clipboard
Better support for custom scalars as input types
Is your feature request related to a problem? Please describe. Consider the following query:
fun echo(json: JsonNode?): JsonNode? = json
The type JsonNode is an abstract class and resolved to a custom scalar as explained in the documentation:
fun schemaGeneratorHooks() = object : SchemaGeneratorHooks {
override fun willGenerateGraphQLType(type: KType): GraphQLType? {
return when (type.classifier) {
JsonNode::class -> jsonScalar
else -> null
}
}
}
However, this does not work. JsonNode is an abstract class, and generateArgument.kt disallows those before resolving the type using the schema generator hooks.
Describe the solution you'd like
Move the check, that no interface / union would be generated from generateArgument.kt to objectFromReflection (of course only check if it is an input type).
Describe alternatives you've considered
Currently, I use a workaround where I use Any as Kotlin type and specify the scalar using @GraphQLType, however, this results in unnecessary casts.
Resolved by https://github.com/ExpediaGroup/graphql-kotlin/pull/1488
I'm not sure if this is resolved
#1488 looks like a client feature to, however this issue was meant as server-related issue
Or did I overlook something?
Ah indeed, closed incorrectly.