作者:麻廿_965 | 来源:互联网 | 2023-07-10 10:58
What happened?
Generated models do not fulfill user defined interfaces provided through models configuration.
1 2 3 4 5 6 7 8 9 10 11
| go
// models/generated.go
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package models
type MyObect struct {
ID string `json:"id"`
}
func (MyObect) IsMyInterface() {} |
What did you expect?
An error preventing me from doing this, OR the generated models need to fulfill the user defined interface, i.e.
1 2 3 4 5 6 7 8 9 10 11
| go
// models/generated.go
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package models
type MyObect struct {
ID string `json:"id"`
}
func (MyObect) Baz() {} |
Minimal graphql.schema and models to reproduce
1 2 3 4 5 6 7 8 9 10
| yml
# .gqlgen.yml
exec:
filename: generated/exec.go
model:
filename: models/generated.go
models:
MyInterface:
model: github.com/99designs/gqlgen/example/interface_failure/models.MyInterface |
1 2 3 4 5 6 7 8 9 10 11 12 13
| graphql
# schema.graphql
interface MyInterface {
id: ID!
}
type MyObect implements MyInterface {
id: ID!
}
type Query {
myObjects: MyObect!
} |
1 2 3 4 5 6 7
| go
// models/my_interface.go
package models
type MyInterface interface {
Baz()
} |
versions
该提问来源于开源项目:99designs/gqlgen
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.