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.
 
 

43 lines
936 B

package queries
import (
"context"
"git.aiterp.net/rpdata/api/graphql/resolver/types"
"git.aiterp.net/rpdata/api/model/channel"
)
// ChannelsArgs is args for channel query
type ChannelsArgs struct {
Filter *struct {
Logged *bool
EventName *string
LocationName *string
}
}
// Channels resolves the channels query
func (r *QueryResolver) Channels(ctx context.Context, args *ChannelsArgs) ([]*types.ChannelResolver, error) {
var channels []channel.Channel
var err error
filter := args.Filter
if filter != nil {
channels, err = channel.List(filter.Logged, filter.EventName, filter.LocationName)
if err != nil {
return nil, err
}
} else {
channels, err = channel.List(nil, nil, nil)
if err != nil {
return nil, err
}
}
resolvers := make([]*types.ChannelResolver, len(channels))
for i := range channels {
resolvers[i] = &types.ChannelResolver{C: channels[i]}
}
return resolvers, nil
}