-
-
Notifications
You must be signed in to change notification settings - Fork 263
Description
GraphQL spec: 3.6.3 Object Extensions
Currently Caliban can parse it, but cannot generate.
Sometimes it leads to issues when a GraphQL schema containing extend type is provided "as is" and cannot be changed, but has to be complied with.
Therefore it could come in really handy to have a possibility to generate extend type too.
Note that a GraphQL schema can have multiple extend type directives for the same type.
Although the feature could be implemented in many different ways, here's one of the ways I could think of personally.
For example, consider the following schema:
type TheQuery {
one: String
}
# first extension
extend type TheQuery {
two: Int
three: Float
}
# second extension
extend type TheQuery {
four: Boolean
}One of the way to handle it could be a new annotation, e.g. @GQLExtendType, which would allow to parse/generate the following model:
case class TheQuery(
one: String,
@GQLExtendType // opens "first extension"
two: Int,
three: Float,
@GQLExtendType // opens "second extension"
four: Boolean
)In other words, @GQLExtendType is applied to a field that opens a new extension group. Each group corresponds to a separate extend type directive in GraphQL. The group continues until the end of the case class or until the next @GQLExtendType is encountered.