models, graph2: Added comment options to chapter mutations.
the build was successful

This commit is contained in:
2019-01-14 17:55:38 +01:00
parent d22ab387dd
commit f9fe0bb5f8
4 changed files with 35 additions and 11 deletions
+7 -2
View File
@@ -48,7 +48,12 @@ func (r *mutationResolver) AddChapter(ctx context.Context, input input.ChapterAd
return models.Chapter{}, errors.New("Story is not open")
}
chapter, err := chapters.Add(story, input.Title, author, input.Source, time.Now(), input.FictionalDate)
commentMode := models.ChapterCommentModeDisabled
if input.CommentMode != nil {
commentMode = *input.CommentMode
}
chapter, err := chapters.Add(story, input.Title, author, input.Source, time.Now(), input.FictionalDate, commentMode)
if err != nil {
return models.Chapter{}, errors.New("Failed to create chapter: " + err.Error())
}
@@ -117,7 +122,7 @@ func (r *mutationResolver) EditChapter(ctx context.Context, input input.ChapterE
input.FictionalDate = &time.Time{}
}
chapter, err = chapters.Edit(chapter, input.Title, input.Source, input.FictionalDate)
chapter, err = chapters.Edit(chapter, input.Title, input.Source, input.FictionalDate, input.CommentMode, input.CommentsLocked)
if err != nil {
return models.Chapter{}, errors.New("Failed to edit chapter: " + err.Error())
}
+9
View File
@@ -70,6 +70,9 @@ input ChapterAddInput {
# Optionally, assign a fictional date for the chapter
fictionalDate: Date
"The comment mode for the chapter."
commentMode: ChapterCommentMode
}
# Input for editChapter mutation
@@ -88,6 +91,12 @@ input ChapterEditInput {
# Remove the fictional date for a chapter
clearFictionalDate: Boolean
"Set the comment mode for the chapter"
commentMode: ChapterCommentMode
"Set whether the chapter comments are locked"
commentsLocked: Boolean
}
# Input for moveChapter mutation