You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
708 B
37 lines
708 B
package resolver
|
|
|
|
import "git.aiterp.net/rpdata/api/model/story"
|
|
|
|
// TagResolver for the Tag graphql type
|
|
type TagResolver struct{ T story.Tag }
|
|
|
|
// TagInput resolves the TagInput input
|
|
type TagInput struct {
|
|
Kind string
|
|
Name string
|
|
}
|
|
|
|
// Tags implements the tags query
|
|
func (r *QueryResolver) Tags() ([]*TagResolver, error) {
|
|
tags, err := story.ListTags()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
resolvers := make([]*TagResolver, len(tags))
|
|
for i, tag := range tags {
|
|
resolvers[i] = &TagResolver{T: tag}
|
|
}
|
|
|
|
return resolvers, nil
|
|
}
|
|
|
|
// Kind resolves Tag.kind
|
|
func (r *TagResolver) Kind() string {
|
|
return r.T.Kind
|
|
}
|
|
|
|
// Name resolves Tag.name
|
|
func (r *TagResolver) Name() string {
|
|
return r.T.Name
|
|
}
|