story-content: Added add chapter

This commit is contained in:
2018-09-20 20:04:02 +02:00
parent 396544e879
commit c40ac40ab5
9 changed files with 175 additions and 9 deletions
+28 -2
View File
@@ -23,7 +23,33 @@ class Chapter {
const chapterApi = {
/**
* Call `editChapter(input)` mutation
* Call `addChapter(input)` mutation, returns the entire object.
*
* @param {{id:string, storyId:string, title:string, author?:string, fictionalDate?:Date, source: string}} input
* @returns {Promise<Chapter>}
*/
addChapter(input) {
return query(`
mutation AddChapter($input: ChapterAddInput!) {
addChapter(input: $input) {
id
title
author
source
createdDate
fictionalDate
editedDate
}
}
`, {input}, {permissions: ["member", "story.add"]}).then((data) => {
const ac = data.addChapter
return new Chapter(ac.id, ac.title, ac.author, ac.source, ac.createdDate, ac.fictionalDate, ac.editedDate)
})
},
/**
* Call `editChapter(input)` mutation, returns editable fields
*
* @param {{id:string, title:string, fictionalDate:Date, source: string}} input
* @returns {Promise<{title:string, fictionalDate:Date, source:string}>}
@@ -47,7 +73,7 @@ const chapterApi = {
},
/**
* Call `removeChapter(input)` mutation
* Call `removeChapter(input)` mutation, returns only the id
*
* @param {{id:string}} input
* @returns {Promise<{id: string}>}