Gisle Aune
6 years ago
4 changed files with 94 additions and 0 deletions
@ -0,0 +1,66 @@ |
|||
package resolver |
|||
|
|||
import ( |
|||
"context" |
|||
"time" |
|||
|
|||
"git.aiterp.net/rpdata/api/model/story" |
|||
) |
|||
|
|||
// ChapterResolver for the Chapter graphql type
|
|||
type ChapterResolver struct{ C story.Chapter } |
|||
|
|||
// ChapterArgs is args for channel query
|
|||
type ChapterArgs struct { |
|||
ID string |
|||
} |
|||
|
|||
// Chapter implements the channel query
|
|||
func (r *QueryResolver) Chapter(ctx context.Context, args *ChapterArgs) (*ChapterResolver, error) { |
|||
chapter, err := story.FindChapterID(args.ID) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
return &ChapterResolver{C: chapter}, nil |
|||
} |
|||
|
|||
// ID resolves Chapter.id
|
|||
func (r *ChapterResolver) ID() string { |
|||
return r.C.ID |
|||
} |
|||
|
|||
// StoryID resolves Chapter.storyId
|
|||
func (r *ChapterResolver) StoryID() string { |
|||
return r.C.StoryID |
|||
} |
|||
|
|||
// Title resolves Chapter.title
|
|||
func (r *ChapterResolver) Title() string { |
|||
return r.C.Title |
|||
} |
|||
|
|||
// Author resolves Chapter.author
|
|||
func (r *ChapterResolver) Author() string { |
|||
return r.C.Author |
|||
} |
|||
|
|||
// Source resolves Chapter.source
|
|||
func (r *ChapterResolver) Source() string { |
|||
return r.C.Source |
|||
} |
|||
|
|||
// CreatedDate resolves Chapter.createdDate
|
|||
func (r *ChapterResolver) CreatedDate() string { |
|||
return r.C.CreatedDate.Format(time.RFC3339Nano) |
|||
} |
|||
|
|||
// FictionalDate resolves Chapter.createdDate
|
|||
func (r *ChapterResolver) FictionalDate() string { |
|||
return r.C.FictionalDate.Format(time.RFC3339Nano) |
|||
} |
|||
|
|||
// EditedDate resolves Chapter.createdDate
|
|||
func (r *ChapterResolver) EditedDate() string { |
|||
return r.C.EditedDate.Format(time.RFC3339Nano) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue