Skip to content

Commit ee9d89c

Browse files
committed
Rename input/output in scalars to parsed/serialized
1 parent 730e529 commit ee9d89c

21 files changed

Lines changed: 179 additions & 178 deletions

File tree

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ export namespace ApolloCache {
4848
export type FromOptionValue<TData> = StoreObject | Reference | FragmentType<NoInfer_2<TData>> | string;
4949
// (undocumented)
5050
export type GetScalarType<TKey extends keyof ApolloCache.Scalars> = ApolloCache.Scalars[TKey] extends ({
51-
input: infer TInput;
52-
output: infer TOutput;
53-
}) ? ApolloCache.Scalar<TInput, TOutput> : never;
51+
serialized: infer TSerialized;
52+
parsed: infer TParsed;
53+
}) ? ApolloCache.Scalar<TSerialized, TParsed> : never;
5454
// (undocumented)
5555
export interface ObservableFragment<TData = unknown> extends Observable<ApolloCache.WatchFragmentResult<TData>> {
5656
getCurrentResult: () => ApolloCache.WatchFragmentResult<TData>;
5757
}
5858
// (undocumented)
59-
export interface Scalar<TInput, TOutput> {
59+
export interface Scalar<TSerialized, TParsed> {
6060
// (undocumented)
6161
devtools: {
62-
displayValue: (parsedValue: TOutput) => unknown;
62+
displayValue: (parsedValue: TParsed) => unknown;
6363
};
6464
// (undocumented)
65-
is: IsLooselyEqual<TInput, TOutput> extends true ? (value: TInput | TOutput) => boolean : (value: TInput | TOutput) => value is TOutput;
65+
is: IsLooselyEqual<TSerialized, TParsed> extends true ? (value: TSerialized | TParsed) => boolean : (value: TSerialized | TParsed) => value is TParsed;
6666
// (undocumented)
67-
parse: (inputValue: TInput) => TOutput;
67+
parse: (serializedValue: TSerialized) => TParsed;
6868
// (undocumented)
69-
serialize: (parsedValue: TOutput) => TInput;
69+
serialize: (parsedValue: TParsed) => TSerialized;
7070
}
7171
// (undocumented)
7272
export interface Scalars {
@@ -576,39 +576,39 @@ const _ignoreModifier: unique symbol;
576576
// @public (undocumented)
577577
export namespace InMemoryCache {
578578
// (undocumented)
579-
export interface ScalarConfig<TInput, TOutput> {
579+
export interface ScalarConfig<TSerialized, TParsed> {
580580
// (undocumented)
581581
devtools?: {
582-
displayValue?(value: TOutput): unknown;
582+
displayValue?(value: TParsed): unknown;
583583
};
584584
// (undocumented)
585-
is?: IsLooselyEqual<TInput, TOutput> extends true ? {
586-
_(value: TInput | TOutput): boolean;
585+
is?: IsLooselyEqual<TSerialized, TParsed> extends true ? {
586+
_(value: TSerialized | TParsed): boolean;
587587
}["_"] : {
588-
_(value: TInput | TOutput): value is TOutput;
588+
_(value: TSerialized | TParsed): value is TParsed;
589589
}["_"];
590590
// (undocumented)
591-
parse(inputValue: TInput): TOutput;
591+
parse(serializedValue: TSerialized): TParsed;
592592
// (undocumented)
593-
serialize(parsedValue: TOutput): TInput;
593+
serialize(parsedValue: TParsed): TSerialized;
594594
}
595595
// Warning: (ae-forgotten-export) The symbol "KnownScalars" needs to be exported by the entry point index.d.ts
596596
//
597597
// (undocumented)
598598
export type ScalarsOption = {
599-
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["input"], KnownScalars[ScalarName]["output"]> extends true ? ScalarName : never]?: KnownScalars[ScalarName] extends ({
600-
input: infer TInput;
601-
output: infer TOutput;
602-
}) ? ScalarConfig<TInput, TOutput> : never;
599+
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["serialized"], KnownScalars[ScalarName]["parsed"]> extends true ? ScalarName : never]?: KnownScalars[ScalarName] extends ({
600+
serialized: infer TSerialized;
601+
parsed: infer TParsed;
602+
}) ? ScalarConfig<TSerialized, TParsed> : never;
603603
} & {
604-
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["input"], KnownScalars[ScalarName]["output"]> extends true ? never : ScalarName]: KnownScalars[ScalarName] extends ({
605-
input: infer TInput;
606-
output: infer TOutput;
607-
}) ? ScalarConfig<TInput, TOutput> : never;
604+
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["serialized"], KnownScalars[ScalarName]["parsed"]> extends true ? never : ScalarName]: KnownScalars[ScalarName] extends ({
605+
serialized: infer TSerialized;
606+
parsed: infer TParsed;
607+
}) ? ScalarConfig<TSerialized, TParsed> : never;
608608
} & (ApolloCache.Scalars extends (Record<string, {
609-
input: infer TInput;
610-
output: infer TOutput;
611-
}>) ? Record<string, ScalarConfig<TInput, TOutput>> : {});
609+
serialized: infer TSerialized;
610+
parsed: infer TParsed;
611+
}>) ? Record<string, ScalarConfig<TSerialized, TParsed>> : {});
612612
}
613613

614614
// @public (undocumented)
@@ -640,7 +640,7 @@ export class InMemoryCache extends ApolloCache {
640640
// @internal @deprecated
641641
getMemoryInternals?: typeof getInMemoryCacheMemoryInternals;
642642
// (undocumented)
643-
getScalar<TKey extends keyof ApolloCache.Scalars>(key: TKey): ApolloCache.GetScalarType<TKey> extends (ApolloCache.Scalar<infer TInput, infer TOutput>) ? IsLooselyEqual<TInput, TOutput> extends true ? ApolloCache.GetScalarType<TKey> | undefined : ApolloCache.GetScalarType<TKey> : never;
643+
getScalar<TKey extends keyof ApolloCache.Scalars>(key: TKey): ApolloCache.GetScalarType<TKey> extends (ApolloCache.Scalar<infer TSerialized, infer TParsed>) ? IsLooselyEqual<TSerialized, TParsed> extends true ? ApolloCache.GetScalarType<TKey> | undefined : ApolloCache.GetScalarType<TKey> : never;
644644
// (undocumented)
645645
identify(object: StoreObject | Reference): string | undefined;
646646
// (undocumented)

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@ export namespace ApolloCache {
4242
export type FromOptionValue<TData> = StoreObject | Reference | FragmentType<NoInfer_2<TData>> | string;
4343
// (undocumented)
4444
export type GetScalarType<TKey extends keyof ApolloCache.Scalars> = ApolloCache.Scalars[TKey] extends ({
45-
input: infer TInput;
46-
output: infer TOutput;
47-
}) ? ApolloCache.Scalar<TInput, TOutput> : never;
45+
serialized: infer TSerialized;
46+
parsed: infer TParsed;
47+
}) ? ApolloCache.Scalar<TSerialized, TParsed> : never;
4848
// (undocumented)
4949
export interface ObservableFragment<TData = unknown> extends Observable<ApolloCache.WatchFragmentResult<TData>> {
5050
getCurrentResult: () => ApolloCache.WatchFragmentResult<TData>;
5151
}
5252
// (undocumented)
53-
export interface Scalar<TInput, TOutput> {
53+
export interface Scalar<TSerialized, TParsed> {
5454
// (undocumented)
5555
devtools: {
56-
displayValue: (parsedValue: TOutput) => unknown;
56+
displayValue: (parsedValue: TParsed) => unknown;
5757
};
5858
// Warning: (ae-forgotten-export) The symbol "IsLooselyEqual" needs to be exported by the entry point index.d.ts
5959
//
6060
// (undocumented)
61-
is: IsLooselyEqual<TInput, TOutput> extends true ? (value: TInput | TOutput) => boolean : (value: TInput | TOutput) => value is TOutput;
61+
is: IsLooselyEqual<TSerialized, TParsed> extends true ? (value: TSerialized | TParsed) => boolean : (value: TSerialized | TParsed) => value is TParsed;
6262
// (undocumented)
63-
parse: (inputValue: TInput) => TOutput;
63+
parse: (serializedValue: TSerialized) => TParsed;
6464
// (undocumented)
65-
serialize: (parsedValue: TOutput) => TInput;
65+
serialize: (parsedValue: TParsed) => TSerialized;
6666
}
6767
// (undocumented)
6868
export interface Scalars {
@@ -1581,39 +1581,39 @@ type InferContextValueFromResolvers<TResolvers> = TResolvers extends {
15811581
// @public (undocumented)
15821582
export namespace InMemoryCache {
15831583
// (undocumented)
1584-
export interface ScalarConfig<TInput, TOutput> {
1584+
export interface ScalarConfig<TSerialized, TParsed> {
15851585
// (undocumented)
15861586
devtools?: {
1587-
displayValue?(value: TOutput): unknown;
1587+
displayValue?(value: TParsed): unknown;
15881588
};
15891589
// (undocumented)
1590-
is?: IsLooselyEqual<TInput, TOutput> extends true ? {
1591-
_(value: TInput | TOutput): boolean;
1590+
is?: IsLooselyEqual<TSerialized, TParsed> extends true ? {
1591+
_(value: TSerialized | TParsed): boolean;
15921592
}["_"] : {
1593-
_(value: TInput | TOutput): value is TOutput;
1593+
_(value: TSerialized | TParsed): value is TParsed;
15941594
}["_"];
15951595
// (undocumented)
1596-
parse(inputValue: TInput): TOutput;
1596+
parse(serializedValue: TSerialized): TParsed;
15971597
// (undocumented)
1598-
serialize(parsedValue: TOutput): TInput;
1598+
serialize(parsedValue: TParsed): TSerialized;
15991599
}
16001600
// Warning: (ae-forgotten-export) The symbol "KnownScalars" needs to be exported by the entry point index.d.ts
16011601
//
16021602
// (undocumented)
16031603
export type ScalarsOption = {
1604-
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["input"], KnownScalars[ScalarName]["output"]> extends true ? ScalarName : never]?: KnownScalars[ScalarName] extends ({
1605-
input: infer TInput;
1606-
output: infer TOutput;
1607-
}) ? ScalarConfig<TInput, TOutput> : never;
1604+
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["serialized"], KnownScalars[ScalarName]["parsed"]> extends true ? ScalarName : never]?: KnownScalars[ScalarName] extends ({
1605+
serialized: infer TSerialized;
1606+
parsed: infer TParsed;
1607+
}) ? ScalarConfig<TSerialized, TParsed> : never;
16081608
} & {
1609-
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["input"], KnownScalars[ScalarName]["output"]> extends true ? never : ScalarName]: KnownScalars[ScalarName] extends ({
1610-
input: infer TInput;
1611-
output: infer TOutput;
1612-
}) ? ScalarConfig<TInput, TOutput> : never;
1609+
[ScalarName in keyof KnownScalars as IsLooselyEqual<KnownScalars[ScalarName]["serialized"], KnownScalars[ScalarName]["parsed"]> extends true ? never : ScalarName]: KnownScalars[ScalarName] extends ({
1610+
serialized: infer TSerialized;
1611+
parsed: infer TParsed;
1612+
}) ? ScalarConfig<TSerialized, TParsed> : never;
16131613
} & (ApolloCache.Scalars extends (Record<string, {
1614-
input: infer TInput;
1615-
output: infer TOutput;
1616-
}>) ? Record<string, ScalarConfig<TInput, TOutput>> : {});
1614+
serialized: infer TSerialized;
1615+
parsed: infer TParsed;
1616+
}>) ? Record<string, ScalarConfig<TSerialized, TParsed>> : {});
16171617
}
16181618

16191619
// @public (undocumented)
@@ -1647,7 +1647,7 @@ export class InMemoryCache extends ApolloCache {
16471647
// @internal @deprecated
16481648
getMemoryInternals?: typeof getInMemoryCacheMemoryInternals;
16491649
// (undocumented)
1650-
getScalar<TKey extends keyof ApolloCache.Scalars>(key: TKey): ApolloCache.GetScalarType<TKey> extends (ApolloCache.Scalar<infer TInput, infer TOutput>) ? IsLooselyEqual<TInput, TOutput> extends true ? ApolloCache.GetScalarType<TKey> | undefined : ApolloCache.GetScalarType<TKey> : never;
1650+
getScalar<TKey extends keyof ApolloCache.Scalars>(key: TKey): ApolloCache.GetScalarType<TKey> extends (ApolloCache.Scalar<infer TSerialized, infer TParsed>) ? IsLooselyEqual<TSerialized, TParsed> extends true ? ApolloCache.GetScalarType<TKey> | undefined : ApolloCache.GetScalarType<TKey> : never;
16511651
// (undocumented)
16521652
identify(object: StoreObject | Reference): string | undefined;
16531653
// (undocumented)

integration-tests/type-tests/customScalars/all-any/differentTypes/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ declare const maybeDate: string | Date;
66

77
declare module "@apollo/client" {
88
namespace ApolloCache {
9-
interface Scalars extends Record<string, { input: any; output: any }> {
10-
DateTime: { input: string; output: Date };
9+
interface Scalars extends Record<string, { serialized: any; parsed: any }> {
10+
DateTime: { serialized: string; parsed: Date };
1111
}
1212
}
1313
}
@@ -45,7 +45,7 @@ test("requires the scalars option for a declared transforming scalar", () => {
4545
});
4646
});
4747

48-
test("serialize receives the output type and parse receives the input type", () => {
48+
test("serialize receives the parsed type and parse receives the serialized type", () => {
4949
new InMemoryCache({
5050
scalars: {
5151
DateTime: {
@@ -72,7 +72,7 @@ test("serialize receives the output type and parse receives the input type", ()
7272
});
7373
});
7474

75-
test("serialize must return the input type", () => {
75+
test("serialize must return the serialized type", () => {
7676
new InMemoryCache({
7777
scalars: {
7878
DateTime: {
@@ -120,7 +120,7 @@ test("serialize must return the input type", () => {
120120
});
121121
});
122122

123-
test("parse must return the output type", () => {
123+
test("parse must return the parsed type", () => {
124124
new InMemoryCache({
125125
scalars: {
126126
DateTime: {
@@ -168,7 +168,7 @@ test("parse must return the output type", () => {
168168
});
169169
});
170170

171-
test("is narrows to the output type when used as a type guard", () => {
171+
test("is narrows to the parsed type when used as a type guard", () => {
172172
const cache = new InMemoryCache({
173173
scalars: {
174174
DateTime: {
@@ -191,7 +191,7 @@ test("is narrows to the output type when used as a type guard", () => {
191191
}
192192
});
193193

194-
test("devtools.displayValue receives the output type", () => {
194+
test("devtools.displayValue receives the parsed type", () => {
195195
new InMemoryCache({
196196
scalars: {
197197
DateTime: {

integration-tests/type-tests/customScalars/all-any/empty/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ declare function test(name: string, fn: () => void): void;
55

66
declare module "@apollo/client" {
77
namespace ApolloCache {
8-
interface Scalars extends Record<string, { input: any; output: any }> {}
8+
interface Scalars
9+
extends Record<string, { serialized: any; parsed: any }> {}
910
}
1011
}
1112

@@ -32,7 +33,7 @@ test("does not require the scalars option", () => {
3233
});
3334
});
3435

35-
test("serialize receives the output type and parse receives the input type", () => {
36+
test("serialize receives the parsed type and parse receives the serialized type", () => {
3637
new InMemoryCache({
3738
scalars: {
3839
RelativeDate: {
@@ -121,7 +122,7 @@ test("parse accepts any return value", () => {
121122
});
122123
});
123124

124-
test("is receives the combined input and output type", () => {
125+
test("is receives the combined serialized and parsed type", () => {
125126
new InMemoryCache({
126127
scalars: {
127128
RelativeDate: {
@@ -136,7 +137,7 @@ test("is receives the combined input and output type", () => {
136137
});
137138
});
138139

139-
test("devtools.displayValue receives the output type", () => {
140+
test("devtools.displayValue receives the parsed type", () => {
140141
new InMemoryCache({
141142
scalars: {
142143
RelativeDate: {

integration-tests/type-tests/customScalars/all-any/matchingTypes/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ declare function test(name: string, fn: () => void): void;
55

66
declare module "@apollo/client" {
77
namespace ApolloCache {
8-
interface Scalars extends Record<string, { input: any; output: any }> {
9-
RelativeDate: { input: string; output: string };
10-
JSONObject: { input: unknown; output: unknown };
8+
interface Scalars extends Record<string, { serialized: any; parsed: any }> {
9+
RelativeDate: { serialized: string; parsed: string };
10+
JSONObject: { serialized: unknown; parsed: unknown };
1111
}
1212
}
1313
}
@@ -57,7 +57,7 @@ test("does not require the scalars option when every scalar matches", () => {
5757
});
5858
});
5959

60-
test("serialize receives the output type and parse receives the input type", () => {
60+
test("serialize receives the parsed type and parse receives the serialized type", () => {
6161
new InMemoryCache({
6262
scalars: {
6363
RelativeDate: {
@@ -94,7 +94,7 @@ test("serialize receives the output type and parse receives the input type", ()
9494
});
9595
});
9696

97-
test("serialize must return the input type", () => {
97+
test("serialize must return the serialized type", () => {
9898
new InMemoryCache({
9999
scalars: {
100100
RelativeDate: {
@@ -142,7 +142,7 @@ test("serialize must return the input type", () => {
142142
});
143143
});
144144

145-
test("parse must return the output type", () => {
145+
test("parse must return the parsed type", () => {
146146
new InMemoryCache({
147147
scalars: {
148148
RelativeDate: {
@@ -190,7 +190,7 @@ test("parse must return the output type", () => {
190190
});
191191
});
192192

193-
test("is receives the combined input and output type", () => {
193+
test("is receives the combined serialized and parsed type", () => {
194194
new InMemoryCache({
195195
scalars: {
196196
RelativeDate: {
@@ -213,7 +213,7 @@ test("is receives the combined input and output type", () => {
213213
});
214214
});
215215

216-
test("devtools.displayValue receives the output type", () => {
216+
test("devtools.displayValue receives the parsed type", () => {
217217
new InMemoryCache({
218218
scalars: {
219219
RelativeDate: {

integration-tests/type-tests/customScalars/all-any/mixed/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ declare function test(name: string, fn: () => void): void;
55

66
declare module "@apollo/client" {
77
namespace ApolloCache {
8-
interface Scalars extends Record<string, { input: any; output: any }> {
9-
DateTime: { input: string; output: Date };
10-
RelativeDate: { input: string; output: string };
8+
interface Scalars extends Record<string, { serialized: any; parsed: any }> {
9+
DateTime: { serialized: string; parsed: Date };
10+
RelativeDate: { serialized: string; parsed: string };
1111
}
1212
}
1313
}
1414

15-
test("requires only the scalars whose input and output differ", () => {
15+
test("requires only the scalars whose serialized and parsed types differ", () => {
1616
// @ts-expect-error `scalars` is required.
1717
new InMemoryCache();
1818

@@ -69,7 +69,7 @@ test("requires only the scalars whose input and output differ", () => {
6969
});
7070
});
7171

72-
test("infers each scalar's input and output types independently", () => {
72+
test("infers each scalar's serialized and parsed types independently", () => {
7373
new InMemoryCache({
7474
scalars: {
7575
DateTime: {

0 commit comments

Comments
 (0)