Skip to content

The willGenerateGraphQLType method should distinguish between input/output graphql types #2120

Description

@a8t3r

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions