Description
My team and I are using graphql-java-kickstart for our kotlin server and want to start using federation.
We succeeded in removing duplicates from the executable schema to pass it into Federation's SchemaTransformer, as will be fixed by the release of this PR provided by @mkaulig.
Now we want to define our entities and their keys in the schema, as described in Apollo's Federation Core Concepts.
When doing so, Federation's SchemaTransformer requires us to provide a TypeResolver for _Entity and DataFetcher for _entities as described here and there is a very basic example here.
I wasn't able to find any support within graphql-java-tools to define the required TypeResolver and DataFetcher. Am I missing something? Is there any support for that in the library?
What I ended up doing for now was to build my own federationEntitiesDictionary as a list of my own EntityDefinition data class:
data class EntityDefinition<T : Any>(
val graphQlTypeName: String,
val typeClass: KClass<T>,
val fetchByIdCallable: KFunction<T?>,
val fetcherInstance: Any
)
I populate this dictionary with EntityDefinition objects for every @key
annotated type in the schema and use it in the required implementations of the TypeResolver and DataFetcher interfaces.
It is working, but I'm not too fond of my low level approach.
Any feedback if this can be done with graphql-java-tools and how is much appreciated!