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.
 
 

37 lines
749 B

package types
import (
"context"
"time"
"git.aiterp.net/rpdata/api/models/chapters"
"git.aiterp.net/rpdata/api/models"
)
type storyResolver struct{}
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) {
chapters, err := chapters.ListStoryID(story.ID)
if err != nil {
return nil, err
}
chapters2 := make([]*models.Chapter, len(chapters))
for i := range chapters {
chapters2[i] = &chapters[i]
}
return chapters2, nil
}
// StoryResolver is a resolver
var StoryResolver storyResolver