Skip to content

Commit

Permalink
fix: update Implements annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Mar 7, 2022
1 parent 36fc419 commit a205a27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions entgql/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type (
// RelayConnection enables the Relay Connection specification for the entity.
// It's also can apply on an edge to create the Relay-style filter.
RelayConnection bool `json:"RelayConnection,omitempty"`
// Implemented are extra interfaces that are implemented.
Implemented []string `json:"Implemented,omitempty"`
// Implements defines a list of interfaces implemented by the type.
Implements []string `json:"Implements,omitempty"`
// Directives to add on the field/type.
Directives []Directive `json:"Directives,omitempty"`
}
Expand Down Expand Up @@ -114,9 +114,9 @@ func RelayConnection() Annotation {
return Annotation{RelayConnection: true}
}

// Implemented returns an Implemented annotation.
func Implemented(interfaces ...string) Annotation {
return Annotation{Implemented: interfaces}
// Implements returns an Implements annotation.
func Implements(interfaces ...string) Annotation {
return Annotation{Implements: interfaces}
}

// Directives returns a Directives annotation.
Expand Down Expand Up @@ -155,8 +155,8 @@ func (a Annotation) Merge(other schema.Annotation) schema.Annotation {
if ant.RelayConnection {
a.RelayConnection = true
}
if len(ant.Implemented) > 0 {
a.Implemented = append(a.Implemented, ant.Implemented...)
if len(ant.Implements) > 0 {
a.Implements = append(a.Implements, ant.Implements...)
}
if len(ant.Directives) > 0 {
a.Directives = append(a.Directives, ant.Directives...)
Expand Down
4 changes: 2 additions & 2 deletions entgql/internal/todoplugin/ent/schema/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (Category) Fields() []ent.Field {
Optional().
Annotations(
entgql.Type("Uint64"),
entgql.Directives(entgql.DeprecatedDirective("We don't use this field anymore")),
entgql.Directives(entgql.Deprecated("We don't use this field anymore")),
),
field.Strings("strings").
Optional(),
Expand All @@ -87,6 +87,6 @@ func (Category) Edges() []ent.Edge {
func (Category) Annotations() []schema.Annotation {
return []schema.Annotation{
entgql.RelayConnection(),
entgql.Implemented("Entity"),
entgql.Implements("Entity"),
}
}
4 changes: 2 additions & 2 deletions entgql/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func (e *schemaGenerator) buildTypes() (map[string]*ast.Definition, error) {
typ.Name = ant.Type
typ.Directives = append(typ.Directives, goModel(e.entGoType(node.Name)))
}
if len(ant.Implemented) > 0 {
typ.Interfaces = append(typ.Interfaces, ant.Implemented...)
if len(ant.Implements) > 0 {
typ.Interfaces = append(typ.Interfaces, ant.Implements...)
}
insertDefinitions(types, typ)

Expand Down

0 comments on commit a205a27

Please sign in to comment.