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.

23 lines
588 B

  1. package queries
  2. import (
  3. "context"
  4. "errors"
  5. "git.aiterp.net/rpdata/api/models"
  6. "git.aiterp.net/rpdata/api/models/characters"
  7. )
  8. func (r *resolver) Character(ctx context.Context, id *string, nick *string) (models.Character, error) {
  9. if id != nil {
  10. return characters.FindID(*id)
  11. } else if nick != nil {
  12. return characters.FindNick(*nick)
  13. } else {
  14. return models.Character{}, errors.New("You must specify either an ID or a nick")
  15. }
  16. }
  17. func (r *resolver) Characters(ctx context.Context, filter *characters.Filter) ([]models.Character, error) {
  18. return characters.List(filter)
  19. }