|
@ -29,7 +29,7 @@ func (r *QueryResolver) Story(ctx context.Context, args *StoryArgs) (*StoryResol |
|
|
|
|
|
|
|
|
// StoriesArg is args for stories query
|
|
|
// StoriesArg is args for stories query
|
|
|
type StoriesArg struct { |
|
|
type StoriesArg struct { |
|
|
Input *struct { |
|
|
|
|
|
|
|
|
Filter *struct { |
|
|
Author *string |
|
|
Author *string |
|
|
Tags *[]TagInput |
|
|
Tags *[]TagInput |
|
|
EarliestFictionalDate *string |
|
|
EarliestFictionalDate *string |
|
@ -40,16 +40,16 @@ type StoriesArg struct { |
|
|
|
|
|
|
|
|
// Stories implements the stories query
|
|
|
// Stories implements the stories query
|
|
|
func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*StoryResolver, error) { |
|
|
func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*StoryResolver, error) { |
|
|
input := args.Input |
|
|
|
|
|
|
|
|
filter := args.Filter |
|
|
|
|
|
|
|
|
author := "" |
|
|
author := "" |
|
|
if input.Author != nil { |
|
|
|
|
|
author = *input.Author |
|
|
|
|
|
|
|
|
if filter != nil && filter.Author != nil { |
|
|
|
|
|
author = *filter.Author |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tags := make([]story.Tag, 0, 8) |
|
|
tags := make([]story.Tag, 0, 8) |
|
|
if input.Tags != nil { |
|
|
|
|
|
for _, tagInput := range *input.Tags { |
|
|
|
|
|
|
|
|
if filter != nil && filter.Tags != nil { |
|
|
|
|
|
for _, tagInput := range *filter.Tags { |
|
|
tags = append(tags, story.Tag{ |
|
|
tags = append(tags, story.Tag{ |
|
|
Kind: tagInput.Kind, |
|
|
Kind: tagInput.Kind, |
|
|
Name: tagInput.Name, |
|
|
Name: tagInput.Name, |
|
@ -59,24 +59,24 @@ func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*Story |
|
|
|
|
|
|
|
|
earliest := time.Time{} |
|
|
earliest := time.Time{} |
|
|
err := error(nil) |
|
|
err := error(nil) |
|
|
if input.EarliestFictionalDate != nil { |
|
|
|
|
|
earliest, err = time.Parse(time.RFC3339Nano, *input.EarliestFictionalDate) |
|
|
|
|
|
|
|
|
if filter != nil && filter.EarliestFictionalDate != nil { |
|
|
|
|
|
earliest, err = time.Parse(time.RFC3339Nano, *filter.EarliestFictionalDate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
latest := time.Time{} |
|
|
latest := time.Time{} |
|
|
if input.LatestFictionalDate != nil { |
|
|
|
|
|
latest, err = time.Parse(time.RFC3339Nano, *input.LatestFictionalDate) |
|
|
|
|
|
|
|
|
if filter != nil && filter.LatestFictionalDate != nil { |
|
|
|
|
|
latest, err = time.Parse(time.RFC3339Nano, *filter.LatestFictionalDate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
limit := 30 |
|
|
limit := 30 |
|
|
if input.Limit != nil { |
|
|
|
|
|
limit = int(*input.Limit) |
|
|
|
|
|
|
|
|
if filter != nil && filter.Limit != nil { |
|
|
|
|
|
limit = int(*filter.Limit) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
stories, err := story.List(author, tags, earliest, latest, limit) |
|
|
stories, err := story.List(author, tags, earliest, latest, limit) |
|
|