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 }