Files
suwayomi-material-you-webui/src/lib/graphql/mutations/MangaMutation.ts
schroda 4a01b1873c Change order of update manga migration
This prevents issues of manga having a specific library state while they are incorrectly in or not in categories.

E.g. a manga was removed from the library but the category update mutation failed, which now causes it to still be in the set categories while not being in the library anymore
2024-08-05 16:07:17 +02:00

216 lines
5.4 KiB
TypeScript

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import gql from 'graphql-tag';
import { MANGA_SCREEN_FIELDS } from '@/lib/graphql/fragments/MangaFragments.ts';
export const DELETE_MANGA_METADATA = gql`
mutation DELETE_MANGA_METADATA($input: DeleteMangaMetaInput!) {
deleteMangaMeta(input: $input) {
meta {
key
value
manga {
id
meta {
key
value
}
}
}
manga {
id
meta {
key
value
}
}
}
}
`;
// makes the server fetch and return the manga
export const GET_MANGA_FETCH = gql`
${MANGA_SCREEN_FIELDS}
mutation GET_MANGA_FETCH($input: FetchMangaInput!) {
fetchManga(input: $input) {
manga {
...MANGA_SCREEN_FIELDS
}
}
}
`;
// makes the server fetch and return the manga
export const GET_MANGA_TO_MIGRATE_TO_FETCH = gql`
mutation GET_MANGA_TO_MIGRATE_TO_FETCH(
$id: Int!
$migrateChapters: Boolean!
$migrateCategories: Boolean!
$migrateTracking: Boolean!
) {
fetchManga(input: { id: $id }) {
manga {
id
title
inLibrary
categories @include(if: $migrateCategories) {
nodes {
id
}
}
trackRecords @include(if: $migrateTracking) {
nodes {
id
remoteId
trackerId
}
}
}
}
fetchChapters(input: { mangaId: $id }) @include(if: $migrateChapters) {
chapters {
id
manga {
id
}
chapterNumber
isRead
isDownloaded
isBookmarked
}
}
}
`;
export const SET_MANGA_METADATA = gql`
mutation SET_MANGA_METADATA($input: SetMangaMetaInput!) {
setMangaMeta(input: $input) {
meta {
key
value
manga {
id
meta {
key
value
}
}
}
}
}
`;
export const UPDATE_MANGA = gql`
mutation UPDATE_MANGA(
$input: UpdateMangaInput!
$updateCategoryInput: UpdateMangaCategoriesInput!
$updateCategories: Boolean!
) {
updateMangaCategories(input: $updateCategoryInput) @include(if: $updateCategories) {
manga {
id
categories {
nodes {
id
mangas {
totalCount
}
}
totalCount
}
}
}
updateManga(input: $input) {
manga {
id
inLibrary
inLibraryAt
}
}
}
`;
export const UPDATE_MANGAS = gql`
mutation UPDATE_MANGAS(
$input: UpdateMangasInput!
$updateCategoryInput: UpdateMangasCategoriesInput!
$updateCategories: Boolean!
) {
updateMangasCategories(input: $updateCategoryInput) @include(if: $updateCategories) {
mangas {
id
categories {
nodes {
id
mangas {
totalCount
}
}
totalCount
}
}
}
updateMangas(input: $input) {
mangas {
id
inLibrary
inLibraryAt
categories {
nodes {
id
mangas {
totalCount
}
}
totalCount
}
}
}
}
`;
export const UPDATE_MANGA_CATEGORIES = gql`
mutation UPDATE_MANGA_CATEGORIES($input: UpdateMangaCategoriesInput!) {
updateMangaCategories(input: $input) {
manga {
id
categories {
nodes {
id
mangas {
totalCount
}
}
totalCount
}
}
}
}
`;
export const UPDATE_MANGAS_CATEGORIES = gql`
mutation UPDATE_MANGAS_CATEGORIES($input: UpdateMangasCategoriesInput!) {
updateMangasCategories(input: $input) {
mangas {
id
categories {
nodes {
id
mangas {
totalCount
}
}
totalCount
}
}
}
}
`;