Skip to content

Commit

Permalink
Create queries, mutations and subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Oct 27, 2023
1 parent ae5d252 commit 55c1c51
Show file tree
Hide file tree
Showing 26 changed files with 1,675 additions and 0 deletions.
439 changes: 439 additions & 0 deletions src/lib/graphql/Fragments.ts

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions src/lib/graphql/mutations/BackupMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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';

export const CREATE_BACKUP = gql`
mutation CREATE_BACKUP($input: CreateBackupInput!) {
createBackup(input: $input) {
clientMutationId
url
}
}
`;

export const RESTORE_BACKUP = gql`
mutation RESTORE_BACKUP($input: RestoreBackupInput!) {
restoreBackup(input: $input) {
clientMutationId
status {
mangaProgress
state
totalManga
}
}
}
`;
105 changes: 105 additions & 0 deletions src/lib/graphql/mutations/CategoryMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* 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 { FULL_CATEGORY_FIELDS } from '@/lib/graphql/Fragments';

export const CREATE_CATEGORY = gql`
${FULL_CATEGORY_FIELDS}
mutation CREATE_CATEGORY($input: CreateCategoryInput!) {
createCategory(input: $input) {
clientMutationId
category {
...FULL_CATEGORY_FIELDS
}
}
}
`;

export const DELETE_CATEGORY = gql`
${FULL_CATEGORY_FIELDS}
mutation DELETE_CATEGORY($input: DeleteCategoryInput!) {
deleteCategory(input: $input) {
clientMutationId
category {
...FULL_CATEGORY_FIELDS
}
}
}
`;

export const DELETE_CATEGORY_METADATA = gql`
${FULL_CATEGORY_FIELDS}
mutation DELETE_CATEGORY_METADATA($input: DeleteCategoryMetaInput!) {
deleteCategoryMeta(input: $input) {
clientMutationId
meta {
key
value
category {
...FULL_CATEGORY_FIELDS
}
}
category {
...FULL_CATEGORY_FIELDS
}
}
}
`;

export const SET_CATEGORY_METADATA = gql`
${FULL_CATEGORY_FIELDS}
mutation SET_CATEGORY_METADATA($input: SetCategoryMetaInput!) {
setCategoryMeta(input: $input) {
clientMutationId
meta {
key
value
category {
...FULL_CATEGORY_FIELDS
}
}
}
}
`;

export const UPDATE_CATEGORY = gql`
${FULL_CATEGORY_FIELDS}
mutation UPDATE_CATEGORY($input: UpdateCategoryInput!) {
updateCategory(input: $input) {
clientMutationId
category {
...FULL_CATEGORY_FIELDS
}
}
}
`;

export const UPDATE_CATEGORIES = gql`
${FULL_CATEGORY_FIELDS}
mutation UPDATE_CATEGORIES($input: UpdateCategoriesInput!) {
updateCategories(input: $input) {
clientMutationId
categories {
...FULL_CATEGORY_FIELDS
}
}
}
`;

export const UPDATE_CATEGORY_ORDER = gql`
${FULL_CATEGORY_FIELDS}
mutation UPDATE_CATEGORY_ORDER($input: UpdateCategoryOrderInput!) {
updateCategoryOrder(input: $input) {
clientMutationId
categories {
...FULL_CATEGORY_FIELDS
}
}
}
`;
96 changes: 96 additions & 0 deletions src/lib/graphql/mutations/ChapterMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 { FULL_CHAPTER_FIELDS } from '@/lib/graphql/Fragments';

export const DELETE_CHAPTER_METADATA = gql`
${FULL_CHAPTER_FIELDS}
mutation DELETE_CHAPTER_METADATA($input: DeleteChapterMetaInput!) {
deleteChapterMeta(input: $input) {
clientMutationId
meta {
key
value
chapter {
...FULL_CHAPTER_FIELDS
}
}
chapter {
...FULL_CHAPTER_FIELDS
}
}
}
`;

// makes the server fetch and return the pages of a chapter
export const GET_CHAPTER_PAGES_FETCH = gql`
${FULL_CHAPTER_FIELDS}
mutation GET_CHAPTER_PAGES_FETCH($input: FetchChapterPagesInput!) {
fetchChapterPages(input: $input) {
clientMutationId
chapter {
...FULL_CHAPTER_FIELDS
}
pages
}
}
`;

// makes the server fetch and return the chapters of the manga
export const GET_MANGA_CHAPTERS_FETCH = gql`
${FULL_CHAPTER_FIELDS}
mutation GET_MANGA_CHAPTERS_FETCH($input: FetchChaptersInput!) {
fetchChapters(input: $input) {
clientMutationId
chapters {
...FULL_CHAPTER_FIELDS
}
}
}
`;

export const SET_CHAPTER_METADATA = gql`
${FULL_CHAPTER_FIELDS}
mutation SET_CHAPTER_METADATA($input: SetChapterMetaInput!) {
setChapterMeta(input: $input) {
clientMutationId
meta {
key
value
chapter {
...FULL_CHAPTER_FIELDS
}
}
}
}
`;

export const UPDATE_CHAPTER = gql`
${FULL_CHAPTER_FIELDS}
mutation UPDATE_CHAPTER($input: UpdateChapterInput!) {
updateChapter(input: $input) {
clientMutationId
chapter {
...FULL_CHAPTER_FIELDS
}
}
}
`;

export const UPDATE_CHAPTERS = gql`
${FULL_CHAPTER_FIELDS}
mutation UPDATE_CHAPTERS($input: UpdateChaptersInput!) {
updateChapters(input: $input) {
clientMutationId
chapters {
...FULL_CHAPTER_FIELDS
}
}
}
`;
130 changes: 130 additions & 0 deletions src/lib/graphql/mutations/DownloaderMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* 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 { FULL_CHAPTER_FIELDS, FULL_DOWNLOAD_STATUS } from '@/lib/graphql/Fragments';

export const CLEAR_DOWNLOADER = gql`
${FULL_DOWNLOAD_STATUS}
mutation CLEAR_DOWNLOADER($input: ClearDownloaderInput = {}) {
clearDownloader(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const DELETE_DOWNLOADED_CHAPTER = gql`
${FULL_CHAPTER_FIELDS}
mutation DELETE_DOWNLOADED_CHAPTER($input: DeleteDownloadedChapterInput!) {
deleteDownloadedChapter(input: $input) {
clientMutationId
chapters {
...FULL_CHAPTER_FIELDS
}
}
}
`;

export const DELETE_DOWNLOADED_CHAPTERS = gql`
${FULL_CHAPTER_FIELDS}
mutation DELETE_DOWNLOADED_CHAPTERS($input: DeleteDownloadedChaptersInput!) {
deleteDownloadedChapters(input: $input) {
clientMutationId
chapters {
...FULL_CHAPTER_FIELDS
}
}
}
`;

export const DEQUEUE_CHAPTER_DOWNLOAD = gql`
${FULL_DOWNLOAD_STATUS}
mutation DEQUEUE_CHAPTER_DOWNLOAD($input: DequeueChapterDownloadInput!) {
dequeueChapterDownload(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const DEQUEUE_CHAPTER_DOWNLOADS = gql`
${FULL_DOWNLOAD_STATUS}
mutation DEQUEUE_CHAPTER_DOWNLOADS($input: DequeueChapterDownloadsInput!) {
dequeueChapterDownloads(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const ENQUEUE_CHAPTER_DOWNLOAD = gql`
${FULL_DOWNLOAD_STATUS}
mutation ENQUEUE_CHAPTER_DOWNLOAD($input: EnqueueChapterDownloadInput!) {
enqueueChapterDownload(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const ENQUEUE_CHAPTER_DOWNLOADS = gql`
${FULL_DOWNLOAD_STATUS}
mutation ENQUEUE_CHAPTER_DOWNLOADS($input: EnqueueChapterDownloadsInput!) {
enqueueChapterDownloads(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const REORDER_CHAPTER_DOWNLOAD = gql`
${FULL_DOWNLOAD_STATUS}
mutation REORDER_CHAPTER_DOWNLOAD($input: ReorderChapterDownloadInput!) {
reorderChapterDownload(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const START_DOWNLOADER = gql`
${FULL_DOWNLOAD_STATUS}
mutation START_DOWNLOADER($input: StartDownloaderInput = {}) {
startDownloader(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;

export const STOP_DOWNLOADER = gql`
${FULL_DOWNLOAD_STATUS}
mutation STOP_DOWNLOADER($input: StopDownloaderInput = {}) {
stopDownloader(input: $input) {
clientMutationId
downloadStatus {
...FULL_DOWNLOAD_STATUS
}
}
}
`;
Loading

0 comments on commit 55c1c51

Please sign in to comment.