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.

32 lines
609 B

  1. package types
  2. import (
  3. "context"
  4. "errors"
  5. "git.aiterp.net/rpdata/api/internal/loader"
  6. "git.aiterp.net/rpdata/api/models"
  7. )
  8. type commentResolver struct{}
  9. func (r *commentResolver) Character(ctx context.Context, obj *models.Comment) (*models.Character, error) {
  10. if obj.CharacterID == "" {
  11. return nil, nil
  12. }
  13. loader := loader.FromContext(ctx)
  14. if loader == nil {
  15. return nil, errors.New("no loader")
  16. }
  17. character, err := loader.Character("id", obj.CharacterID)
  18. if err != nil {
  19. return nil, err
  20. }
  21. return &character, nil
  22. }
  23. // CommentResolver is a resolver
  24. var CommentResolver commentResolver