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.
49 lines
1.3 KiB
49 lines
1.3 KiB
package resolvers
|
|
|
|
import (
|
|
"context"
|
|
"git.aiterp.net/rpdata/api/graph2/graphcore"
|
|
"git.aiterp.net/rpdata/api/models"
|
|
)
|
|
|
|
// Queries
|
|
|
|
func (r *queryResolver) Channel(ctx context.Context, name string) (*models.Channel, error) {
|
|
return r.s.Channels.Find(ctx, name)
|
|
}
|
|
|
|
func (r *queryResolver) Channels(ctx context.Context, filter *models.ChannelFilter) ([]*models.Channel, error) {
|
|
if filter == nil {
|
|
filter = &models.ChannelFilter{}
|
|
}
|
|
|
|
return r.s.Channels.List(ctx, *filter)
|
|
}
|
|
|
|
// Mutations
|
|
|
|
func (r *mutationResolver) AddChannel(ctx context.Context, input graphcore.ChannelAddInput) (*models.Channel, error) {
|
|
logged := input.Logged != nil && *input.Logged
|
|
hub := input.Hub != nil && *input.Hub
|
|
|
|
locationName := ""
|
|
if input.LocationName != nil {
|
|
locationName = *input.LocationName
|
|
}
|
|
|
|
eventName := ""
|
|
if input.LocationName != nil {
|
|
eventName = *input.EventName
|
|
}
|
|
|
|
return r.s.Channels.Create(ctx, input.Name, logged, hub, eventName, locationName)
|
|
}
|
|
|
|
func (r *mutationResolver) EditChannel(ctx context.Context, input graphcore.ChannelEditInput) (*models.Channel, error) {
|
|
return r.s.Channels.Update(ctx, input.Name, models.ChannelUpdate{
|
|
Logged: input.Logged,
|
|
Hub: input.Hub,
|
|
EventName: input.EventName,
|
|
LocationName: input.LocationName,
|
|
})
|
|
}
|