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.

25 lines
564 B

  1. package queries
  2. import (
  3. "context"
  4. "errors"
  5. "git.aiterp.net/rpdata/api/models"
  6. "git.aiterp.net/rpdata/api/models/changes"
  7. )
  8. /// Queries
  9. func (r *resolver) Changes(ctx context.Context, filter *changes.Filter) ([]models.Change, error) {
  10. return changes.List(filter)
  11. }
  12. /// Subscriptions
  13. func (r *subscriptionResolver) Changes(ctx context.Context, keys []models.ChangeKey) (<-chan *models.Change, error) {
  14. if len(keys) == 0 {
  15. return nil, errors.New("At least one key is required for a subscription")
  16. }
  17. return changes.Subscribe(ctx, keys, false), nil
  18. }