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 { Logged *bool } // Channels resolves the channels query func (r *QueryResolver) Channels(ctx context.Context, args *ChannelsArgs) ([]*types.ChannelResolver, error) { channels, err := channel.List(args.Logged != nil && *args.Logged) 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 }