[Proposal] Support embeding via extraFields attribute
tsirolnik opened this issue · comments
Suppose I want to add an embedded struct to a generated model, as far as I understand, this is not possible at the moment.
My proposal is to allow embedding via a modification to the extraFields attribute of models in the gqlgen.yml
file.
By adding an attribute of, for example - embedded: true
the extra field will only embed the type instead of adding it as an attribute to the struct.
So the following example -
models:
User:
extraFields:
Session:
description: "A Session used by this user"
type: "github.com/author/mypkg.Session"
embedded: True
will generate
type User struct {
ID string
Name string
// A Session used by this user.
mypkg.Session
}
This solution will allow to add out of the box support for embedding with , IMO, minimal required changes.
This is especially useful when using 3rd party libraries such as gorm, i.e users of gorm frequently use the gorm.Model
type by embedding into their model definitions.
If this sounds like something is desired I will be more than happy to try and create a pr for that.