-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Federation entity resolver generation #1454
Comments
Workaround for anyone else who comes across this: Add a custom model for the type for the entity being extended, in this example package model
type User struct {
ID string `json:"id"`
}
func (User) IsEntity() {} And the model to the config -
|
Yep, looks like this doesn't quite work correctly without a custom model. The work around (use custom models) is annoying, but looks like it generates the correct code and isn't functionally different. |
Actually, looks like it's specifically to do with the fields generated in the model extend type Product @key(fields: "upc") {
upc: String! @external
reviews: [Review]
} Won't work with a model like type Product struct {
Upc string `json:"upc"`
Reviews []*Review `json:"reviews"`
} The |
Another solution to have the resolvers without a custom model is to force them in the models:
User:
fields:
reviews:
resolver: true
Product:
fields:
reviews:
resolver: true |
A combination of #1388 & #1429
What happened?
{Entity}Resolver
's are not generated (example example/federation/reviews/graph/schema.resolvers.go) without specifying an explicit custom model (e.g. example/federation/reviews/graph/model/models.go)Replication in the examples:
What did you expect?
I expected that generated Entitys would also generate the EntityResolver's? Is this not the case by design?
Minimal graphql.schema and models to reproduce
versions
gqlgen version
? v0.13.0go version
? 1.14Notes
Looking into the code a little more, I assume the issue is arising from
codegen/config/config.go
-Init()
The text was updated successfully, but these errors were encountered: