story-content: Added add chapter
This commit is contained in:
+28
-2
@@ -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}>}
|
||||
|
||||
Reference in New Issue
Block a user