GraphQL API and utilities for the rpdata project
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

  1. package resolver
  2. import "git.aiterp.net/rpdata/api/model/story"
  3. // TagResolver for the Tag graphql type
  4. type TagResolver struct{ T story.Tag }
  5. // TagInput resolves the TagInput input
  6. type TagInput struct {
  7. Kind string
  8. Name string
  9. }
  10. // Tags implements the tags query
  11. func (r *QueryResolver) Tags() ([]*TagResolver, error) {
  12. tags, err := story.ListTags()
  13. if err != nil {
  14. return nil, err
  15. }
  16. resolvers := make([]*TagResolver, len(tags))
  17. for i, tag := range tags {
  18. resolvers[i] = &TagResolver{T: tag}
  19. }
  20. return resolvers, nil
  21. }
  22. // Kind resolves Tag.kind
  23. func (r *TagResolver) Kind() string {
  24. return r.T.Kind
  25. }
  26. // Name resolves Tag.name
  27. func (r *TagResolver) Name() string {
  28. return r.T.Name
  29. }