package types import ( "context" "errors" "git.aiterp.net/rpdata/api/internal/loader" "git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models/posts" ) type logResolver struct{} func (r *logResolver) Channel(ctx context.Context, log *models.Log) (models.Channel, error) { loader := loader.FromContext(ctx) if loader == nil { return models.Channel{}, errors.New("no loader") } return loader.Channel("name", log.ChannelName) } func (r *logResolver) Characters(ctx context.Context, log *models.Log) ([]models.Character, error) { loader := loader.FromContext(ctx) if loader == nil { return nil, errors.New("no loader") } return loader.Characters("id", log.CharacterIDs...) } func (r *logResolver) Posts(ctx context.Context, log *models.Log, kinds []string) ([]models.Post, error) { return posts.List(&posts.Filter{ LogID: &log.ShortID, Kind: kinds, Limit: 0, }) } // LogResolver is a resolver var LogResolver logResolver