Skip to content

Impossible to update description by directive #738

Open
@romash1408

Description

@romash1408

I am trying to somehow mark fields that have applied directive

@Component
class AuthDirective {
    @Bean
    fun authDirectiveWiring() = SchemaDirective("auth", AuthDirectiveWiring())

    inner class AuthDirectiveWiring : SchemaDirectiveWiring {
        override fun onField(environment: SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition>): GraphQLFieldDefinition {
            val requiredScopes = environment.appliedDirective.getArgument("scopes").getValue<List<String>>()

            val field = environment.fieldDefinition

            // some logic with environment.codeRegistry.dataFetcher and scopes check

            val originalDescription = if (field.description.isNullOrBlank()) "" else "${field.description}\n\n"
            val description = "${originalDescription}@auth(${requiredScopes})"

            // transform rerturns new field definition with new description, but original definition in registry still has old description
            return field.transform {
                it.description(description)
            }
        }
    }
}

but later on this line my changed field definition is just thrown out

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions