GraphQL API and utilities for the rpdata project
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.
 
 

30 lines
663 B

package types
import (
"context"
"git.aiterp.net/rpdata/api/services"
"time"
"git.aiterp.net/rpdata/api/models"
)
type storyResolver struct {
stories *services.StoryService
}
func (r *storyResolver) FictionalDate(ctx context.Context, story *models.Story) (*time.Time, error) {
if story.FictionalDate.IsZero() {
return nil, nil
}
return &story.FictionalDate, nil
}
func (r *storyResolver) Chapters(ctx context.Context, story *models.Story) ([]*models.Chapter, error) {
return r.stories.ListChapters(ctx, *story)
}
// StoryResolver is a resolver
func StoryResolver(s *services.Bundle) *storyResolver {
return &storyResolver{stories: s.Stories}
}