Skip to content

Commit 1c6e03c

Browse files
committed
allow Complete and Partial datastate type overrides (#12740)
1 parent b845906 commit 1c6e03c

21 files changed

+973
-468
lines changed

.api-reports/api-report-cache.api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import type { ApolloCache as ApolloCache_2 } from '@apollo/client';
88
import type { AsStoreObject } from '@apollo/client/utilities';
99
import { canonicalStringify } from '@apollo/client/utilities';
10+
import type { DataValue } from '@apollo/client';
1011
import type { DeepPartial } from '@apollo/client/utilities';
1112
import type { DocumentNode } from 'graphql';
1213
import type { FieldNode } from 'graphql';
@@ -222,12 +223,12 @@ export function createFragmentRegistry(...fragments: DocumentNode[]): FragmentRe
222223
export namespace DataProxy {
223224
// (undocumented)
224225
export type DiffResult<TData> = {
225-
result: TData;
226+
result: DataValue.Complete<TData>;
226227
complete: true;
227228
missing?: never;
228229
fromOptimisticTransaction?: boolean;
229230
} | {
230-
result: DeepPartial<TData> | null;
231+
result: DataValue.Partial<TData> | null;
231232
complete: false;
232233
missing?: MissingFieldError;
233234
fromOptimisticTransaction?: boolean;

.api-reports/api-report-core.api.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,27 @@ export { DataProxy }
230230

231231
// @public (undocumented)
232232
export type DataState<TData> = {
233-
data: TData;
233+
data: DataValue.Complete<TData>;
234234
dataState: "complete";
235235
} | {
236-
data: Streaming<TData>;
236+
data: DataValue.Streaming<TData>;
237237
dataState: "streaming";
238238
} | {
239-
data: DeepPartial<TData>;
239+
data: DataValue.Partial<TData>;
240240
dataState: "partial";
241241
} | {
242242
data: undefined;
243243
dataState: "empty";
244244
};
245245

246+
// @public (undocumented)
247+
export namespace DataValue {
248+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
249+
export type Complete<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Complete", OverridableTypes.Defaults, TData>;
250+
export type Partial<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Partial", OverridableTypes.Defaults, TData>;
251+
export type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
252+
}
253+
246254
// @public (undocumented)
247255
export interface DefaultContext extends Record<string, any> {
248256
// (undocumented)
@@ -512,13 +520,7 @@ export { NormalizedCache }
512520
export { NormalizedCacheObject }
513521

514522
// @public
515-
export type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & ({
516-
data: TData;
517-
dataState: "complete";
518-
} | {
519-
data: Streaming<TData>;
520-
dataState: "streaming";
521-
});
523+
export type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & GetDataState<TData, "streaming" | "complete">;
522524

523525
export { Observable }
524526

@@ -623,14 +625,36 @@ export { OptimisticStoreItem }
623625

624626
// @public (undocumented)
625627
namespace OverridableTypes {
628+
// (undocumented)
629+
interface Complete extends HKT {
630+
// (undocumented)
631+
arg1: unknown;
632+
// (undocumented)
633+
return: this["arg1"];
634+
}
626635
// (undocumented)
627636
interface Defaults {
637+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
638+
//
639+
// (undocumented)
640+
Complete: Complete;
641+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
642+
//
643+
// (undocumented)
644+
Partial: Partial;
628645
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
629646
//
630647
// (undocumented)
631648
Streaming: Streaming;
632649
}
633650
// (undocumented)
651+
interface Partial extends HKT {
652+
// (undocumented)
653+
arg1: unknown;
654+
// (undocumented)
655+
return: DeepPartial<this["arg1"]>;
656+
}
657+
// (undocumented)
634658
interface Streaming extends HKT {
635659
// (undocumented)
636660
arg1: unknown;
@@ -878,11 +902,6 @@ export { StoreObject }
878902

879903
export { StoreValue }
880904

881-
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
882-
//
883-
// @public
884-
export type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
885-
886905
// @public (undocumented)
887906
export interface SubscribeResult<TData = unknown> {
888907
data: TData | undefined;

.api-reports/api-report-react.api.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,27 @@ export function createQueryPreloader(client: ApolloClient): PreloadQueryFunction
239239

240240
// @public (undocumented)
241241
type DataState<TData> = {
242-
data: TData;
242+
data: DataValue.Complete<TData>;
243243
dataState: "complete";
244244
} | {
245-
data: Streaming<TData>;
245+
data: DataValue.Streaming<TData>;
246246
dataState: "streaming";
247247
} | {
248-
data: DeepPartial<TData>;
248+
data: DataValue.Partial<TData>;
249249
dataState: "partial";
250250
} | {
251251
data: undefined;
252252
dataState: "empty";
253253
};
254254

255+
// @public (undocumented)
256+
namespace DataValue {
257+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
258+
type Complete<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Complete", OverridableTypes.Defaults, TData>;
259+
type Partial<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Partial", OverridableTypes.Defaults, TData>;
260+
type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
261+
}
262+
255263
// @public (undocumented)
256264
interface DefaultContext extends Record<string, any> {
257265
// (undocumented)
@@ -495,13 +503,7 @@ interface NextFetchPolicyContext<TData, TVariables extends OperationVariables_2>
495503
}
496504

497505
// @public
498-
type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & ({
499-
data: TData;
500-
dataState: "complete";
501-
} | {
502-
data: Streaming<TData>;
503-
dataState: "streaming";
504-
});
506+
type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & GetDataState<TData, "streaming" | "complete">;
505507

506508
// @public (undocumented)
507509
interface ObservableAndInfo<TData> {
@@ -609,14 +611,36 @@ type OperationVariables_2 = Record<string, any>;
609611

610612
// @public (undocumented)
611613
namespace OverridableTypes {
614+
// (undocumented)
615+
interface Complete extends HKT {
616+
// (undocumented)
617+
arg1: unknown;
618+
// (undocumented)
619+
return: this["arg1"];
620+
}
612621
// (undocumented)
613622
interface Defaults {
623+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
624+
//
625+
// (undocumented)
626+
Complete: Complete;
627+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
628+
//
629+
// (undocumented)
630+
Partial: Partial;
614631
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
615632
//
616633
// (undocumented)
617634
Streaming: Streaming;
618635
}
619636
// (undocumented)
637+
interface Partial extends HKT {
638+
// (undocumented)
639+
arg1: unknown;
640+
// (undocumented)
641+
return: DeepPartial<this["arg1"]>;
642+
}
643+
// (undocumented)
620644
interface Streaming extends HKT {
621645
// (undocumented)
622646
arg1: unknown;
@@ -884,11 +908,6 @@ export type SkipToken = typeof skipToken;
884908
// @public (undocumented)
885909
export const skipToken: unique symbol;
886910

887-
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
888-
//
889-
// @public
890-
type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
891-
892911
// @public (undocumented)
893912
interface SubscribeResult<TData = unknown> {
894913
data: TData | undefined;
@@ -1624,10 +1643,10 @@ type WatchQueryOptions_2<TVariables extends OperationVariables_2 = OperationVari
16241643
// src/core/ObservableQuery.ts:157:5 - (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts
16251644
// src/core/ObservableQuery.ts:305:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
16261645
// src/core/QueryManager.ts:187:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
1627-
// src/core/types.ts:236:3 - (ae-forgotten-export) The symbol "ErrorLike" needs to be exported by the entry point index.d.ts
1628-
// src/core/types.ts:238:3 - (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts
1629-
// src/core/types.ts:255:7 - (ae-forgotten-export) The symbol "Streaming" needs to be exported by the entry point index.d.ts
1630-
// src/core/types.ts:308:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
1646+
// src/core/types.ts:313:3 - (ae-forgotten-export) The symbol "ErrorLike" needs to be exported by the entry point index.d.ts
1647+
// src/core/types.ts:315:3 - (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts
1648+
// src/core/types.ts:327:7 - (ae-forgotten-export) The symbol "DataValue" needs to be exported by the entry point index.d.ts
1649+
// src/core/types.ts:374:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
16311650
// src/core/watchQueryOptions.ts:178:3 - (ae-forgotten-export) The symbol "UpdateQueryOptions" needs to be exported by the entry point index.d.ts
16321651
// src/core/watchQueryOptions.ts:261:3 - (ae-forgotten-export) The symbol "MutationQueryReducersMap" needs to be exported by the entry point index.d.ts
16331652
// src/core/watchQueryOptions.ts:264:3 - (ae-forgotten-export) The symbol "NormalizedExecutionResult" needs to be exported by the entry point index.d.ts

.api-reports/api-report.api.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,12 @@ export interface DataMasking {
491491
export namespace DataProxy {
492492
// (undocumented)
493493
export type DiffResult<TData> = {
494-
result: TData;
494+
result: DataValue.Complete<TData>;
495495
complete: true;
496496
missing?: never;
497497
fromOptimisticTransaction?: boolean;
498498
} | {
499-
result: DeepPartial<TData> | null;
499+
result: DataValue.Partial<TData> | null;
500500
complete: false;
501501
missing?: MissingFieldError;
502502
fromOptimisticTransaction?: boolean;
@@ -554,19 +554,28 @@ export interface DataProxy {
554554

555555
// @public (undocumented)
556556
export type DataState<TData> = {
557-
data: TData;
557+
data: DataValue.Complete<TData>;
558558
dataState: "complete";
559559
} | {
560-
data: Streaming<TData>;
560+
data: DataValue.Streaming<TData>;
561561
dataState: "streaming";
562562
} | {
563-
data: DeepPartial<TData>;
563+
data: DataValue.Partial<TData>;
564564
dataState: "partial";
565565
} | {
566566
data: undefined;
567567
dataState: "empty";
568568
};
569569

570+
// @public (undocumented)
571+
export namespace DataValue {
572+
// Warning: (ae-forgotten-export) The symbol "ApplyHKTImplementationWithDefault" needs to be exported by the entry point index.d.ts
573+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
574+
export type Complete<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Complete", OverridableTypes.Defaults, TData>;
575+
export type Partial<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Partial", OverridableTypes.Defaults, TData>;
576+
export type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
577+
}
578+
570579
// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts
571580
// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts
572581
// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts
@@ -577,6 +586,8 @@ export type DataState<TData> = {
577586
// @public
578587
type DeepPartial<T> = T extends DeepPartialPrimitive ? T : T extends Map<infer TKey, infer TValue> ? DeepPartialMap<TKey, TValue> : T extends ReadonlyMap<infer TKey, infer TValue> ? DeepPartialReadonlyMap<TKey, TValue> : T extends Set<infer TItem> ? DeepPartialSet<TItem> : T extends ReadonlySet<infer TItem> ? DeepPartialReadonlySet<TItem> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray<infer TItem>) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray<DeepPartial<TItem | undefined>> : Array<DeepPartial<TItem | undefined>> : DeepPartialObject<T> : DeepPartialObject<T> : unknown;
579588

589+
// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts
590+
//
580591
// @public (undocumented)
581592
type DeepPartialMap<TKey, TValue> = {} & Map<DeepPartial<TKey>, DeepPartial<TValue>>;
582593

@@ -947,7 +958,6 @@ interface FragmentRegistryAPI {
947958
transform<D extends DocumentNode>(document: D): D;
948959
}
949960

950-
// Warning: (ae-forgotten-export) The symbol "ApplyHKTImplementationWithDefault" needs to be exported by the entry point index.d.ts
951961
// Warning: (ae-forgotten-export) The symbol "DefaultImplementation" needs to be exported by the entry point index.d.ts
952962
//
953963
// @public (undocumented)
@@ -1840,13 +1850,7 @@ export interface NormalizedCacheObject {
18401850
}
18411851

18421852
// @public
1843-
export type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & ({
1844-
data: TData;
1845-
dataState: "complete";
1846-
} | {
1847-
data: Streaming<TData>;
1848-
dataState: "streaming";
1849-
});
1853+
export type NormalizedExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Omit<FormattedExecutionResult<TData, TExtensions>, "data"> & GetDataState<TData, "streaming" | "complete">;
18501854

18511855
export { Observable }
18521856

@@ -1979,14 +1983,36 @@ export type OptimisticStoreItem = {
19791983

19801984
// @public (undocumented)
19811985
namespace OverridableTypes {
1986+
// (undocumented)
1987+
interface Complete extends HKT {
1988+
// (undocumented)
1989+
arg1: unknown;
1990+
// (undocumented)
1991+
return: this["arg1"];
1992+
}
19821993
// (undocumented)
19831994
interface Defaults {
1995+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
1996+
//
1997+
// (undocumented)
1998+
Complete: Complete;
1999+
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
2000+
//
2001+
// (undocumented)
2002+
Partial: Partial;
19842003
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
19852004
//
19862005
// (undocumented)
19872006
Streaming: Streaming;
19882007
}
19892008
// (undocumented)
2009+
interface Partial extends HKT {
2010+
// (undocumented)
2011+
arg1: unknown;
2012+
// (undocumented)
2013+
return: DeepPartial<this["arg1"]>;
2014+
}
2015+
// (undocumented)
19902016
interface Streaming extends HKT {
19912017
// (undocumented)
19922018
arg1: unknown;
@@ -2431,11 +2457,6 @@ Item
24312457
// @public
24322458
export type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
24332459

2434-
// Warning: (ae-forgotten-export) The symbol "OverridableTypes" needs to be exported by the entry point index.d.ts
2435-
//
2436-
// @public
2437-
export type Streaming<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Streaming", OverridableTypes.Defaults, TData>;
2438-
24392460
// @public (undocumented)
24402461
class Stump extends Layer {
24412462
constructor(root: EntityStore.Root);
@@ -2686,7 +2707,6 @@ interface WriteContext extends ReadMergeModifyContext {
26862707

26872708
// Warnings were encountered during analysis:
26882709
//
2689-
// src/cache/core/types/DataProxy.ts:137:9 - (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts
26902710
// src/cache/inmemory/policies.ts:97:3 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
26912711
// src/cache/inmemory/policies.ts:166:3 - (ae-forgotten-export) The symbol "KeySpecifier" needs to be exported by the entry point index.d.ts
26922712
// src/cache/inmemory/policies.ts:166:3 - (ae-forgotten-export) The symbol "KeyArgsFunction" needs to be exported by the entry point index.d.ts

0 commit comments

Comments
 (0)