🪢Added resolvers for lib, dashboard endpoints

This commit is contained in:
2026-03-04 21:49:38 -05:00
parent 8c224bad68
commit 22cbdcd468
9 changed files with 1846 additions and 10 deletions

View File

@@ -0,0 +1,248 @@
/**
* GraphQL query to fetch complete comic detail data
*
* This file should be placed in the frontend project at:
* src/client/graphql/queries/comicDetail.ts
*
* Matches the data structure expected by ComicDetail component
*/
export const GET_COMIC_DETAIL_QUERY = `
query GetComicDetail($id: ID!) {
comic(id: $id) {
id
# Raw file information
rawFileDetails {
name
filePath
fileSize
extension
mimeType
containedIn
pageCount
archive {
uncompressed
expandedPath
}
cover {
filePath
stats
}
}
# Inferred metadata from filename parsing
inferredMetadata {
issue {
name
number
year
subtitle
}
}
# Sourced metadata from various providers
sourcedMetadata {
comicInfo
comicvine
metron
gcd
locg {
name
publisher
url
cover
description
price
rating
pulls
potw
}
}
# Import status
importStatus {
isImported
tagged
matchedResult {
score
}
}
# Acquisition/download information
acquisition {
source {
wanted
name
}
directconnect {
downloads {
bundleId
name
size
}
}
torrent {
infoHash
name
announce
}
}
# Timestamps
createdAt
updatedAt
}
}
`;
/**
* TypeScript type for the query response
* Generated from GraphQL schema
*/
export interface ComicDetailQueryResponse {
comic: {
id: string;
rawFileDetails?: {
name?: string;
filePath?: string;
fileSize?: number;
extension?: string;
mimeType?: string;
containedIn?: string;
pageCount?: number;
archive?: {
uncompressed?: boolean;
expandedPath?: string;
};
cover?: {
filePath?: string;
stats?: any;
};
};
inferredMetadata?: {
issue?: {
name?: string;
number?: number;
year?: string;
subtitle?: string;
};
};
sourcedMetadata?: {
comicInfo?: string; // JSON string - needs parsing
comicvine?: string; // JSON string - needs parsing
metron?: string; // JSON string - needs parsing
gcd?: string; // JSON string - needs parsing
locg?: {
name?: string;
publisher?: string;
url?: string;
cover?: string;
description?: string;
price?: string;
rating?: number;
pulls?: number;
potw?: number;
};
};
importStatus?: {
isImported?: boolean;
tagged?: boolean;
matchedResult?: {
score?: string;
};
};
acquisition?: {
source?: {
wanted?: boolean;
name?: string;
};
directconnect?: {
downloads?: Array<{
bundleId?: number;
name?: string;
size?: string;
}>;
};
torrent?: Array<{
infoHash?: string;
name?: string;
announce?: string[];
}>;
};
createdAt?: string;
updatedAt?: string;
};
}
/**
* Minimal query for basic comic information
* Use this when you only need basic details
*/
export const GET_COMIC_BASIC_QUERY = `
query GetComicBasic($id: ID!) {
comic(id: $id) {
id
rawFileDetails {
name
filePath
fileSize
pageCount
}
inferredMetadata {
issue {
name
number
year
}
}
}
}
`;
/**
* Query for comic metadata only (no file details)
* Use this when you only need metadata
*/
export const GET_COMIC_METADATA_QUERY = `
query GetComicMetadata($id: ID!) {
comic(id: $id) {
id
sourcedMetadata {
comicInfo
comicvine
metron
gcd
locg {
name
publisher
description
rating
}
}
canonicalMetadata {
title {
value
provenance {
source
confidence
}
}
series {
value
provenance {
source
confidence
}
}
publisher {
value
provenance {
source
confidence
}
}
}
}
}
`;

View File

@@ -0,0 +1,260 @@
/**
* GraphQL queries for library operations
* Examples for getComicBooks, getComicBookGroups, getLibraryStatistics, and searchIssue
*/
/**
* Query to get comic books with pagination and filtering
*/
export const GET_COMIC_BOOKS = `
query GetComicBooks($paginationOptions: PaginationOptionsInput!, $predicate: PredicateInput) {
getComicBooks(paginationOptions: $paginationOptions, predicate: $predicate) {
docs {
id
canonicalMetadata {
title {
value
provenance {
source
confidence
}
}
series {
value
}
issueNumber {
value
}
publisher {
value
}
coverImage {
value
}
}
rawFileDetails {
name
filePath
fileSize
extension
}
createdAt
updatedAt
}
totalDocs
limit
page
totalPages
hasNextPage
hasPrevPage
nextPage
prevPage
pagingCounter
}
}
`;
/**
* Query to get comic book groups (volumes)
*/
export const GET_COMIC_BOOK_GROUPS = `
query GetComicBookGroups {
getComicBookGroups {
id
volumes {
id
name
count_of_issues
publisher {
id
name
}
start_year
image {
medium_url
thumb_url
}
description
site_detail_url
}
}
}
`;
/**
* Query to get library statistics
*/
export const GET_LIBRARY_STATISTICS = `
query GetLibraryStatistics {
getLibraryStatistics {
totalDocuments
comicDirectorySize {
totalSize
totalSizeInMB
totalSizeInGB
fileCount
}
statistics {
fileTypes {
id
data
}
publisherWithMostComicsInLibrary {
id
count
}
}
}
}
`;
/**
* Example usage with variables for getComicBooks
*/
export const exampleGetComicBooksVariables = {
paginationOptions: {
page: 1,
limit: 10,
sort: "-createdAt", // Sort by creation date, descending
lean: false,
pagination: true,
},
predicate: {
// Optional: Add filters here
// Example: { "canonicalMetadata.publisher.value": "Marvel" }
},
};
/**
* Example: Get first page of comics
*/
export const exampleGetFirstPage = {
query: GET_COMIC_BOOKS,
variables: {
paginationOptions: {
page: 1,
limit: 20,
sort: "-createdAt",
},
},
};
/**
* Example: Get comics with specific filters
*/
export const exampleGetFilteredComics = {
query: GET_COMIC_BOOKS,
variables: {
paginationOptions: {
page: 1,
limit: 10,
},
predicate: {
"importStatus.isImported": true,
},
},
};
/**
* Query to search issues using Elasticsearch
*/
export const SEARCH_ISSUE = `
query SearchIssue($query: SearchIssueQueryInput, $pagination: SearchPaginationInput, $type: SearchType!) {
searchIssue(query: $query, pagination: $pagination, type: $type) {
hits {
total {
value
relation
}
max_score
hits {
_index
_id
_score
_source {
id
canonicalMetadata {
title {
value
}
series {
value
}
issueNumber {
value
}
publisher {
value
}
}
rawFileDetails {
name
filePath
}
}
}
}
took
timed_out
}
}
`;
/**
* Example: Search all comics
*/
export const exampleSearchAll = {
query: SEARCH_ISSUE,
variables: {
type: "all",
pagination: {
size: 10,
from: 0,
},
},
};
/**
* Example: Search by volume name
*/
export const exampleSearchByVolumeName = {
query: SEARCH_ISSUE,
variables: {
query: {
volumeName: "Spider-Man",
},
type: "volumeName",
pagination: {
size: 20,
from: 0,
},
},
};
/**
* Example: Search wanted comics
*/
export const exampleSearchWanted = {
query: SEARCH_ISSUE,
variables: {
type: "wanted",
pagination: {
size: 50,
from: 0,
},
},
};
/**
* Example: Search volumes
*/
export const exampleSearchVolumes = {
query: SEARCH_ISSUE,
variables: {
type: "volumes",
pagination: {
size: 10,
from: 0,
},
},
};