+23
-5
@@ -21,7 +21,7 @@ class Chapter {
|
||||
}
|
||||
}
|
||||
|
||||
const chapterApi = {
|
||||
class ChapterAPI {
|
||||
/**
|
||||
* Call `addChapter(input)` mutation, returns the entire object.
|
||||
*
|
||||
@@ -46,7 +46,7 @@ const chapterApi = {
|
||||
|
||||
return new Chapter(ac.id, ac.title, ac.author, ac.source, ac.createdDate, ac.fictionalDate, ac.editedDate)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `editChapter(input)` mutation, returns editable fields
|
||||
@@ -70,7 +70,25 @@ const chapterApi = {
|
||||
|
||||
return editChapter
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `moveChapter(input)` mutation, returns the ID.
|
||||
*
|
||||
* @param {{id:string, storyId:string}} input
|
||||
* @returns {Promise<{id:string}>}
|
||||
*/
|
||||
moveChapter(input) {
|
||||
return query(`
|
||||
mutation MoveChapter($input: ChapterMoveInput!) {
|
||||
moveChapter(input: $input) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`, {input}, {permissions: ["member", "story.move"]}).then(({moveChapter}) => {
|
||||
return moveChapter
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `removeChapter(input)` mutation, returns only the id
|
||||
@@ -88,7 +106,7 @@ const chapterApi = {
|
||||
`, {input}, {permissions: ["member", "story.edit"]}).then(({removeChapter}) => {
|
||||
return removeChapter
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {Chapter, chapterApi}
|
||||
module.exports = {Chapter, chapterApi: new ChapterAPI}
|
||||
Reference in New Issue
Block a user