From 4a01b1873ce85c55b086c1255711bc39bdb78575 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:54:24 +0200 Subject: [PATCH] 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 --- src/lib/graphql/generated/graphql.ts | 4 ++-- src/lib/graphql/mutations/MangaMutation.ts | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index 9db0c984..378a6958 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -3057,7 +3057,7 @@ export type UpdateMangaMutationVariables = Exact<{ }>; -export type UpdateMangaMutation = { __typename?: 'Mutation', updateManga?: { __typename?: 'UpdateMangaPayload', manga: { __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: string } } | null, updateMangaCategories?: { __typename?: 'UpdateMangaCategoriesPayload', manga: { __typename?: 'MangaType', id: number, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } } } | null }; +export type UpdateMangaMutation = { __typename?: 'Mutation', updateMangaCategories?: { __typename?: 'UpdateMangaCategoriesPayload', manga: { __typename?: 'MangaType', id: number, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } } } | null, updateManga?: { __typename?: 'UpdateMangaPayload', manga: { __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: string } } | null }; export type UpdateMangasMutationVariables = Exact<{ input: UpdateMangasInput; @@ -3066,7 +3066,7 @@ export type UpdateMangasMutationVariables = Exact<{ }>; -export type UpdateMangasMutation = { __typename?: 'Mutation', updateMangas?: { __typename?: 'UpdateMangasPayload', mangas: Array<{ __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: string, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } }> } | null, updateMangasCategories?: { __typename?: 'UpdateMangasCategoriesPayload', mangas: Array<{ __typename?: 'MangaType', id: number, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } }> } | null }; +export type UpdateMangasMutation = { __typename?: 'Mutation', updateMangasCategories?: { __typename?: 'UpdateMangasCategoriesPayload', mangas: Array<{ __typename?: 'MangaType', id: number, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } }> } | null, updateMangas?: { __typename?: 'UpdateMangasPayload', mangas: Array<{ __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: string, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } }> } | null }; export type UpdateMangaCategoriesMutationVariables = Exact<{ input: UpdateMangaCategoriesInput; diff --git a/src/lib/graphql/mutations/MangaMutation.ts b/src/lib/graphql/mutations/MangaMutation.ts index 792cb3c5..9aca2cfc 100644 --- a/src/lib/graphql/mutations/MangaMutation.ts +++ b/src/lib/graphql/mutations/MangaMutation.ts @@ -113,13 +113,6 @@ export const UPDATE_MANGA = gql` $updateCategoryInput: UpdateMangaCategoriesInput! $updateCategories: Boolean! ) { - updateManga(input: $input) { - manga { - id - inLibrary - inLibraryAt - } - } updateMangaCategories(input: $updateCategoryInput) @include(if: $updateCategories) { manga { id @@ -134,6 +127,13 @@ export const UPDATE_MANGA = gql` } } } + updateManga(input: $input) { + manga { + id + inLibrary + inLibraryAt + } + } } `; @@ -143,11 +143,9 @@ export const UPDATE_MANGAS = gql` $updateCategoryInput: UpdateMangasCategoriesInput! $updateCategories: Boolean! ) { - updateMangas(input: $input) { + updateMangasCategories(input: $updateCategoryInput) @include(if: $updateCategories) { mangas { id - inLibrary - inLibraryAt categories { nodes { id @@ -159,9 +157,11 @@ export const UPDATE_MANGAS = gql` } } } - updateMangasCategories(input: $updateCategoryInput) @include(if: $updateCategories) { + updateMangas(input: $input) { mangas { id + inLibrary + inLibraryAt categories { nodes { id