graphql-kotlin icon indicating copy to clipboard operation
graphql-kotlin copied to clipboard

The willGenerateGraphQLType method should distinguish between input/output graphql types

Open a8t3r opened this issue 4 months ago • 0 comments

Is your feature request related to a problem? Please describe. The SchemaGeneratorHooks.willGenerateGraphQLType method is called when generating both input and output types, but the context of the call is not known and it is not clear which graphql type is expected. The problem occurs when the same KType is used for both input and output.

Describe the solution you'd like It would be better to change the signature of the method to willGenerateGraphQLType(type: KType, typeInfo: GraphQLKTypeMetadata). The typeInfo is already known in the call context:

internal fun generateGraphQLType(generator: SchemaGenerator, type: KType, typeInfo: GraphQLKTypeMetadata = GraphQLKTypeMetadata()): GraphQLType {
    val hookGraphQLType = generator.config.hooks.willGenerateGraphQLType(type)
...

Describe alternatives you've considered Alternatively typeInfo may be reduced to boolean:

generator.config.hooks.willGenerateGraphQLType(type, typeInfo.inputType)

a8t3r avatar Jun 12 '25 12:06 a8t3r