Browse Source
Moved StoryResolver and TagResolver into resolvers/types package, updated references to it.
1.0
Moved StoryResolver and TagResolver into resolvers/types package, updated references to it.
1.0
Gisle Aune
6 years ago
4 changed files with 118 additions and 105 deletions
@ -0,0 +1,80 @@ |
|||||
|
package types |
||||
|
|
||||
|
import ( |
||||
|
"time" |
||||
|
|
||||
|
"git.aiterp.net/rpdata/api/model/story" |
||||
|
) |
||||
|
|
||||
|
// StoryResolver for the Story graphql type
|
||||
|
type StoryResolver struct{ S story.Story } |
||||
|
|
||||
|
// ID resolves Story.id
|
||||
|
func (r *StoryResolver) ID() string { |
||||
|
return r.S.ID |
||||
|
} |
||||
|
|
||||
|
// Author resolves Story.author
|
||||
|
func (r *StoryResolver) Author() string { |
||||
|
return r.S.Author |
||||
|
} |
||||
|
|
||||
|
// Name resolves Story.name
|
||||
|
func (r *StoryResolver) Name() string { |
||||
|
return r.S.Name |
||||
|
} |
||||
|
|
||||
|
// Category resolves Story.category
|
||||
|
func (r *StoryResolver) Category() string { |
||||
|
return r.S.Category |
||||
|
} |
||||
|
|
||||
|
// Open resolves Story.open
|
||||
|
func (r *StoryResolver) Open() bool { |
||||
|
return r.S.Open |
||||
|
} |
||||
|
|
||||
|
// Listed resolves Story.listed
|
||||
|
func (r *StoryResolver) Listed() bool { |
||||
|
return r.S.Listed |
||||
|
} |
||||
|
|
||||
|
// Tags resolves Story.tags
|
||||
|
func (r *StoryResolver) Tags() []*TagResolver { |
||||
|
resolvers := make([]*TagResolver, len(r.S.Tags)) |
||||
|
for i, tag := range r.S.Tags { |
||||
|
resolvers[i] = &TagResolver{T: tag} |
||||
|
} |
||||
|
|
||||
|
return resolvers |
||||
|
} |
||||
|
|
||||
|
// Chapters resolves Story.chapters
|
||||
|
func (r *StoryResolver) Chapters() ([]*ChapterResolver, error) { |
||||
|
chapters, err := r.S.Chapters() |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
resolvers := make([]*ChapterResolver, len(chapters)) |
||||
|
for i, chapter := range chapters { |
||||
|
resolvers[i] = &ChapterResolver{C: chapter} |
||||
|
} |
||||
|
|
||||
|
return resolvers, nil |
||||
|
} |
||||
|
|
||||
|
// CreatedDate resolves Story.createdDate
|
||||
|
func (r *StoryResolver) CreatedDate() string { |
||||
|
return r.S.CreatedDate.Format(time.RFC3339Nano) |
||||
|
} |
||||
|
|
||||
|
// FictionalDate resolves Story.fictionalDate
|
||||
|
func (r *StoryResolver) FictionalDate() string { |
||||
|
return r.S.FictionalDate.Format(time.RFC3339Nano) |
||||
|
} |
||||
|
|
||||
|
// UpdatedDate resolves Story.updatedDate
|
||||
|
func (r *StoryResolver) UpdatedDate() string { |
||||
|
return r.S.UpdatedDate.Format(time.RFC3339Nano) |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package types |
||||
|
|
||||
|
import "git.aiterp.net/rpdata/api/model/story" |
||||
|
|
||||
|
// TagResolver for the Tag graphql type
|
||||
|
type TagResolver struct{ T story.Tag } |
||||
|
|
||||
|
// Kind resolves Tag.kind
|
||||
|
func (r *TagResolver) Kind() string { |
||||
|
return r.T.Kind |
||||
|
} |
||||
|
|
||||
|
// Name resolves Tag.name
|
||||
|
func (r *TagResolver) Name() string { |
||||
|
return r.T.Name |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue