Adding directives to schema without being directly consumed by a type #1455
-
Hi I saw in the documentation here that we are able to add additional custom types to the schema without being directly consumed by any existing types. My question is there a way to do the same for directives? E.g. I have some directives that are currently not being referenced by any types in the schema but I would like to include them in the outputted GraphQLSchema. (Apologies if this seems something obvious that I missed in the docs) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello 👋 You could either
fun generateSchema(...) {
val originalSchema = super.generateSchema(...)
val updatedSchema = originalSchema.transform { builder ->
// your logic goes here
}
}
In either case you would need to manually create your directive definitions and them to the builder. builder.additionalDirective(<your directive definition goes here>) |
Beta Was this translation helpful? Give feedback.
Hello 👋
It is doable but will require some manual code.
You could either
SchemaGenerator/FederatedSchemaGenerator
and transform your schema ingenerateSchema
, i.e.FederatedSchemaGeneratorHooks
) and add your directives in thewillBuildSchema(builder: builder: GraphQLSchema.Builder)
hookIn either case you would need to manually create your directive definitions and them to the builder.