Right now, my project uses netflix/springboot/kotlin.
I want to have an SDL like:
type Shows {
name: String!
writer: Writer!
}
type Writer {
name: String!
}
In this case, a show must have a writer.
When I codegen, I get the relevant Kotlin types.
Now, if I want to implement:
...
@DgsData(parent = 'Query', field = 'show')
fun show(@InputArgument id: String): GeneratedShow {
val show = ShowService.getShow(id);
// I can't return `show` here because `show` only has `name` and `writerId`.
}
My ShowService.getShow
type only returns a name
and a writerId
and I don't want to force my function to have to "hydrate" (extra network call) the writer
on every graphql call. This would be a waste of resources even if my client does not specify the writer
subfield.
But I cannot get this to compile because this function requires a writer
field on it. I also don't want to make writer
a nullable field in my schema, because it is required.
How do you solve this issue?