Fix typing after "apollo-client" update to v3.12.4
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
useQuery,
|
||||
useSubscription,
|
||||
} from '@apollo/client';
|
||||
import { OperationVariables, Reference } from '@apollo/client/core';
|
||||
import { MaybeMasked, OperationVariables, Reference } from '@apollo/client/core';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { IRestClient, RestClient } from '@/lib/requests/client/RestClient.ts';
|
||||
import { GraphQLClient } from '@/lib/requests/client/GraphQLClient.ts';
|
||||
@@ -380,12 +380,12 @@ type AbortableRequest = { abortRequest: AbortController['abort'] };
|
||||
type ImageRequest = { response: Promise<string>; cleanup: () => void } & AbortableRequest;
|
||||
|
||||
export type AbortabaleApolloQueryResponse<Data = any> = {
|
||||
response: Promise<ApolloQueryResult<Data>>;
|
||||
response: Promise<ApolloQueryResult<MaybeMasked<Data>>>;
|
||||
} & AbortableRequest;
|
||||
export type AbortableApolloUseQueryResponse<
|
||||
Data = any,
|
||||
Variables extends OperationVariables = OperationVariables,
|
||||
> = QueryResult<Data, Variables> & AbortableRequest;
|
||||
> = QueryResult<MaybeMasked<Data>, Variables> & AbortableRequest;
|
||||
export type AbortableApolloUseMutationResponse<
|
||||
Data = any,
|
||||
Variables extends OperationVariables = OperationVariables,
|
||||
@@ -394,7 +394,7 @@ export type AbortableApolloUseMutationPaginatedResponse<
|
||||
Data = any,
|
||||
Variables extends OperationVariables = OperationVariables,
|
||||
> = [
|
||||
(page: number) => Promise<FetchResult<Data>>,
|
||||
(page: number) => Promise<FetchResult<MaybeMasked<Data>>>,
|
||||
(Omit<MutationTuple<Data, Variables>[1], 'loading'> &
|
||||
AbortableRequest & {
|
||||
size: number;
|
||||
@@ -413,7 +413,9 @@ export type AbortableApolloUseMutationPaginatedResponse<
|
||||
isValidating: boolean;
|
||||
})[],
|
||||
];
|
||||
export type AbortableApolloMutationResponse<Data = any> = { response: Promise<FetchResult<Data>> } & AbortableRequest;
|
||||
export type AbortableApolloMutationResponse<Data = any> = {
|
||||
response: Promise<FetchResult<MaybeMasked<Data>>>;
|
||||
} & AbortableRequest;
|
||||
|
||||
const EXTENSION_LIST_CACHE_KEY = 'useExtensionListFetch';
|
||||
|
||||
@@ -517,9 +519,9 @@ export class RequestManager {
|
||||
options: ApolloPaginatedMutationOptions<Data, Variables> | undefined,
|
||||
checkIfCachedPageIsInvalid: (
|
||||
cachedResult: AbortableApolloUseMutationPaginatedResponse<Data, Variables>[1][number] | undefined,
|
||||
revalidatedResult: FetchResult<Data>,
|
||||
revalidatedResult: FetchResult<MaybeMasked<Data>>,
|
||||
) => boolean,
|
||||
hasNextPage: (revalidatedResult: FetchResult<Data>) => boolean,
|
||||
hasNextPage: (revalidatedResult: FetchResult<MaybeMasked<Data>>) => boolean,
|
||||
pageToRevalidate: number,
|
||||
maxPage: number,
|
||||
signal: AbortSignal,
|
||||
@@ -656,7 +658,7 @@ export class RequestManager {
|
||||
cacheResultsKey: string,
|
||||
cachedPages: Set<number>,
|
||||
newPage: number,
|
||||
): Promise<FetchResult<Data>> {
|
||||
): Promise<FetchResult<MaybeMasked<Data>>> {
|
||||
const basePaginatedResult: Partial<AbortableApolloUseMutationPaginatedResponse<Data, Variables>[1][number]> = {
|
||||
size: newPage,
|
||||
isLoading: false,
|
||||
@@ -664,7 +666,7 @@ export class RequestManager {
|
||||
called: true,
|
||||
};
|
||||
|
||||
let response: FetchResult<Data> = {};
|
||||
let response: FetchResult<MaybeMasked<Data>> = {};
|
||||
try {
|
||||
const { signal, abortRequest } = this.createAbortController();
|
||||
setAbortRequest(abortRequest);
|
||||
@@ -769,7 +771,7 @@ export class RequestManager {
|
||||
cachedResults: AbortableApolloUseMutationPaginatedResponse<Data, Variables>[1][number][],
|
||||
getVariablesFor: (page: number) => Variables,
|
||||
paginatedResult: AbortableApolloUseMutationPaginatedResponse<Data, Variables>[1][number],
|
||||
fetchPage: (page: number) => Promise<FetchResult<Data>>,
|
||||
fetchPage: (page: number) => Promise<FetchResult<MaybeMasked<Data>>>,
|
||||
hasCachedResult: boolean,
|
||||
createPaginatedResult: (
|
||||
result: Partial<AbortableApolloUseMutationPaginatedResponse<Data, Variables>[1][number]>,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import { t as translate } from 'i18next';
|
||||
import gql from 'graphql-tag';
|
||||
import { DocumentNode } from '@apollo/client';
|
||||
import { DocumentNode, Unmasked } from '@apollo/client';
|
||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { getMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||
@@ -108,7 +108,7 @@ export class Chapters {
|
||||
id: number,
|
||||
fragment: DocumentNode = CHAPTER_LIST_FIELDS,
|
||||
fragmentName: string = 'CHAPTER_LIST_FIELDS',
|
||||
): T | null {
|
||||
): Unmasked<T> | null {
|
||||
return requestManager.graphQLClient.client.cache.readFragment<T>({
|
||||
id: requestManager.graphQLClient.client.cache.identify({
|
||||
__typename: 'ChapterType',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { t as translate } from 'i18next';
|
||||
import { DocumentNode } from '@apollo/client/core';
|
||||
import { DocumentNode, Unmasked } from '@apollo/client/core';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import {
|
||||
ChapterConditionInput,
|
||||
@@ -93,7 +93,7 @@ export class Mangas {
|
||||
id: MangaIdInfo['id'],
|
||||
fragment: DocumentNode = MANGA_BASE_FIELDS,
|
||||
fragmentName: string = 'MANGA_BASE_FIELDS',
|
||||
): T | null {
|
||||
): Unmasked<T> | null {
|
||||
return requestManager.graphQLClient.client.cache.readFragment<T>({
|
||||
id: requestManager.graphQLClient.client.cache.identify({
|
||||
__typename: 'MangaType',
|
||||
|
||||
Reference in New Issue
Block a user