Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to update description by directive #738

Open
romash1408 opened this issue Mar 13, 2023 · 0 comments
Open

Impossible to update description by directive #738

romash1408 opened this issue Mar 13, 2023 · 0 comments

Comments

@romash1408
Copy link

romash1408 commented Mar 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant