Skip to content

Adding directives to schema without being directly consumed by a type #1455

Answered by dariuszkuc
Barry-Zou asked this question in Q&A
Discussion options

You must be logged in to vote

Hello 👋
It is doable but will require some manual code.

You could either

  • extend SchemaGenerator/FederatedSchemaGenerator and transform your schema in generateSchema, i.e.
fun generateSchema(...) {
  val originalSchema = super.generateSchema(...)
  val updatedSchema = originalSchema.transform { builder ->
     // your logic goes here
  }
}
  • provide custom SchemaGeneratorHooks (or FederatedSchemaGeneratorHooks) and add your directives in the willBuildSchema(builder: builder: GraphQLSchema.Builder) hook

In either case you would need to manually create your directive definitions and them to the builder.

builder.additionalDirective(<your directive definition goes here>)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Barry-Zou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants