Impossible to update description by directive
romash1408 opened this issue · 0 comments
romash1408 commented
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