Skip to main content
Version: 3.x.x

Advanced Features

Adding Custom Additional Types#

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.


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.


This method is called by SchemaGenerator::get after all the queries, mutations, and subscriptions have been generated and it is going to add all the types saved in an internal set that were not generated by reflection. To change the behaviour, you can update the set and then call the super method with the new value.


class CustomSchemaGenerator(config: SchemaGeneratorConfig) : SchemaGenerator(config) {
override fun generateAdditionalTypes(types: Set<KType>): Set<GraphQLType> {
val newTypes = types.toMutableSet().add(MyNewType()::class.createType())
return super.generateAdditionalTypes(newTypes)
Last updated on by jgorman-exp