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.
35 lines
766 B
35 lines
766 B
package types
|
|
|
|
import (
|
|
"context"
|
|
"git.aiterp.net/rpdata/api/services"
|
|
"time"
|
|
|
|
"git.aiterp.net/rpdata/api/models"
|
|
)
|
|
|
|
type chapterResolver struct {
|
|
stories *services.StoryService
|
|
}
|
|
|
|
func (r *chapterResolver) FictionalDate(ctx context.Context, chapter *models.Chapter) (*time.Time, error) {
|
|
if chapter.FictionalDate.IsZero() {
|
|
return nil, nil
|
|
}
|
|
|
|
return &chapter.FictionalDate, nil
|
|
}
|
|
|
|
func (r *chapterResolver) Comments(ctx context.Context, chapter *models.Chapter, limit *int) ([]*models.Comment, error) {
|
|
if limit == nil {
|
|
limit = new(int)
|
|
*limit = 0
|
|
}
|
|
|
|
return r.stories.ListComments(ctx, *chapter, *limit)
|
|
}
|
|
|
|
// ChapterResolver is a resolver
|
|
func ChapterResolver(s *services.Bundle) *chapterResolver {
|
|
return &chapterResolver{stories: s.Stories}
|
|
}
|