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.

29 lines
645 B

  1. package types
  2. import (
  3. "context"
  4. "log"
  5. "git.aiterp.net/rpdata/api/graph2/input"
  6. "git.aiterp.net/rpdata/api/models"
  7. )
  8. type changeResolver struct{}
  9. func (r *changeResolver) Objects(ctx context.Context, obj *models.Change) ([]input.ChangeObject, error) {
  10. objects := obj.Objects()
  11. results := make([]input.ChangeObject, 0, len(objects))
  12. for _, object := range objects {
  13. if changeObject, ok := object.(input.ChangeObject); ok {
  14. results = append(results, changeObject)
  15. } else {
  16. log.Printf("Type %T needs ChangeObject impl", object)
  17. }
  18. }
  19. return results, nil
  20. }
  21. // ChangeResolver is a resolver
  22. var ChangeResolver changeResolver