There are a couple ways you can add more types to the schema without having them be directly consumed by a type in your schema. This may be required for Apollo Federation, or maybe adding other interface implementations that are not picked up.
When generating a schema you can optionally specify additional types and input types to be included in the schema. This will
allow you to link to those types from your custom
SchemaGeneratorHooks implementation using GraphQL reference instead of
manually creating the underlying GraphQL type.
val myConfig = SchemaGeneratorConfig(supportedPackages = listOf("com.example"))val generator = SchemaGenerator(myConfig) val schema = generator.generateSchema( queries = myQueries, additionalTypes = setOf(MyCustomObject::class.createType()), additionalInputTypes = setOf(MyCustomInputObject::class.createType()))
This method is protected so if you override the
SchemaGenerator used you can call this method to add types that have a specific annotation.
You can see how this is used in
graphql-kotlin-federation as an example.