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.

28 lines
650 B

  1. package queries
  2. import (
  3. "context"
  4. "git.aiterp.net/rpdata/api/graphql/resolver/types"
  5. "git.aiterp.net/rpdata/api/model/channel"
  6. )
  7. // ChannelsArgs is args for channel query
  8. type ChannelsArgs struct {
  9. Logged *bool
  10. }
  11. // Channels resolves the channels query
  12. func (r *QueryResolver) Channels(ctx context.Context, args *ChannelsArgs) ([]*types.ChannelResolver, error) {
  13. channels, err := channel.List(args.Logged != nil && *args.Logged)
  14. if err != nil {
  15. return nil, err
  16. }
  17. resolvers := make([]*types.ChannelResolver, len(channels))
  18. for i := range channels {
  19. resolvers[i] = &types.ChannelResolver{C: channels[i]}
  20. }
  21. return resolvers, nil
  22. }