Skip to content

Commit bfcfc90

Browse files
committed
Rename Unmask back to Unmasked. Remove Mask in favor of MaybeMasked.
1 parent 6e74f21 commit bfcfc90

18 files changed

Lines changed: 110 additions & 121 deletions

File tree

src/cache/core/__tests__/cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expectTypeOf } from "expect-type";
22
import type { FragmentDefinitionNode, InlineFragmentNode } from "graphql";
33
import { gql } from "graphql-tag";
44

5-
import type { OperationVariables, Unmask } from "@apollo/client";
5+
import type { OperationVariables, Unmasked } from "@apollo/client";
66
import type { Cache } from "@apollo/client/cache";
77
import { ApolloCache } from "@apollo/client/cache";
88

@@ -39,7 +39,7 @@ class TestCache extends ApolloCache {
3939
public read<
4040
TData = unknown,
4141
TVariables extends OperationVariables = OperationVariables,
42-
>(query: Cache.ReadOptions<TData, TVariables>): Unmask<TData> | null {
42+
>(query: Cache.ReadOptions<TData, TVariables>): Unmasked<TData> | null {
4343
return null;
4444
}
4545

src/cache/core/cache.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
OperationVariables,
1313
TypedDocumentNode,
1414
} from "@apollo/client";
15-
import type { FragmentType, Unmask } from "@apollo/client/masking";
15+
import type { FragmentType, Unmasked } from "@apollo/client/masking";
1616
import type { Reference, StoreObject } from "@apollo/client/utilities";
1717
import { cacheSizes } from "@apollo/client/utilities";
1818
import { __DEV__ } from "@apollo/client/utilities/environment";
@@ -103,7 +103,7 @@ export abstract class ApolloCache {
103103
public abstract read<
104104
TData = unknown,
105105
TVariables extends OperationVariables = OperationVariables,
106-
>(query: Cache.ReadOptions<TData, TVariables>): Unmask<TData> | null;
106+
>(query: Cache.ReadOptions<TData, TVariables>): Unmasked<TData> | null;
107107
public abstract write<
108108
TData = unknown,
109109
TVariables extends OperationVariables = OperationVariables,
@@ -258,7 +258,7 @@ export abstract class ApolloCache {
258258
id,
259259
optimistic,
260260
returnPartialData,
261-
}: Cache.ReadQueryOptions<TData, TVariables>): Unmask<TData> | null;
261+
}: Cache.ReadQueryOptions<TData, TVariables>): Unmasked<TData> | null;
262262
/**
263263
* {@inheritDoc @apollo/client!ApolloCache#readQuery:member(1)}
264264
*/
@@ -272,14 +272,14 @@ export abstract class ApolloCache {
272272
* instead of passing it as a separate option.
273273
*/
274274
optimistic: boolean
275-
): Unmask<TData> | null;
275+
): Unmasked<TData> | null;
276276
public readQuery<
277277
TData = unknown,
278278
TVariables extends OperationVariables = OperationVariables,
279279
>(
280280
options: Cache.ReadQueryOptions<TData, TVariables>,
281281
optimistic = !!options.optimistic
282-
): Unmask<TData> | null {
282+
): Unmasked<TData> | null {
283283
return this.read({
284284
...options,
285285
rootId: options.id || "ROOT_QUERY",
@@ -293,7 +293,7 @@ export abstract class ApolloCache {
293293
TVariables extends OperationVariables = OperationVariables,
294294
>(
295295
options: ApolloCache.WatchFragmentOptions<TData, TVariables>
296-
): Observable<ApolloCache.WatchFragmentResult<Unmask<TData>>> {
296+
): Observable<ApolloCache.WatchFragmentResult<Unmasked<TData>>> {
297297
const {
298298
fragment,
299299
fragmentName,
@@ -365,7 +365,7 @@ export abstract class ApolloCache {
365365
data,
366366
dataState: diff.complete ? "complete" : "partial",
367367
complete: !!diff.complete,
368-
} as ApolloCache.WatchFragmentResult<Unmask<TData>>;
368+
} as ApolloCache.WatchFragmentResult<Unmasked<TData>>;
369369

370370
if (diff.missing) {
371371
result.missing = diff.missing.missing;
@@ -401,7 +401,7 @@ export abstract class ApolloCache {
401401
id,
402402
optimistic,
403403
returnPartialData,
404-
}: Cache.ReadFragmentOptions<TData, TVariables>): Unmask<TData> | null;
404+
}: Cache.ReadFragmentOptions<TData, TVariables>): Unmasked<TData> | null;
405405
public readFragment<
406406
TData = unknown,
407407
TVariables extends OperationVariables = OperationVariables,
@@ -412,14 +412,14 @@ export abstract class ApolloCache {
412412
* instead of passing it as a separate option.
413413
*/
414414
optimistic: boolean
415-
): Unmask<TData> | null;
415+
): Unmasked<TData> | null;
416416
public readFragment<
417417
TData = unknown,
418418
TVariables extends OperationVariables = OperationVariables,
419419
>(
420420
options: Cache.ReadFragmentOptions<TData, TVariables>,
421421
optimistic = !!options.optimistic
422-
): Unmask<TData> | null {
422+
): Unmasked<TData> | null {
423423
return this.read({
424424
...options,
425425
query: this.getFragmentDoc(options.fragment, options.fragmentName),
@@ -503,8 +503,8 @@ export abstract class ApolloCache {
503503
TVariables extends OperationVariables = OperationVariables,
504504
>(
505505
options: Cache.UpdateQueryOptions<TData, TVariables>,
506-
update: (data: Unmask<TData> | null) => Unmask<TData> | null | void
507-
): Unmask<TData> | null {
506+
update: (data: Unmasked<TData> | null) => Unmasked<TData> | null | void
507+
): Unmasked<TData> | null {
508508
return this.batch({
509509
update(cache) {
510510
const value = cache.readQuery<TData, TVariables>(options);
@@ -521,8 +521,8 @@ export abstract class ApolloCache {
521521
TVariables extends OperationVariables = OperationVariables,
522522
>(
523523
options: Cache.UpdateFragmentOptions<TData, TVariables>,
524-
update: (data: Unmask<TData> | null) => Unmask<TData> | null | void
525-
): Unmask<TData> | null {
524+
update: (data: Unmasked<TData> | null) => Unmasked<TData> | null | void
525+
): Unmasked<TData> | null {
526526
return this.batch({
527527
update(cache) {
528528
const value = cache.readFragment<TData, TVariables>(options);

src/cache/core/types/Cache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
OperationVariables,
55
TypedDocumentNode,
66
} from "@apollo/client";
7-
import type { Unmask } from "@apollo/client/masking";
7+
import type { Unmasked } from "@apollo/client/masking";
88

99
import type { ApolloCache } from "../cache.js";
1010

@@ -64,7 +64,7 @@ export declare namespace Cache {
6464
variables?: TVariables;
6565

6666
dataId?: string;
67-
result: Unmask<TData>;
67+
result: Unmasked<TData>;
6868

6969
/**
7070
* Whether to notify query watchers.
@@ -264,7 +264,7 @@ export declare namespace Cache {
264264
/**
265265
* The data to write to the store.
266266
*/
267-
data: Unmask<TData>;
267+
data: Unmasked<TData>;
268268
/**
269269
* Whether to notify query watchers.
270270
* @defaultValue true
@@ -312,7 +312,7 @@ export declare namespace Cache {
312312
/**
313313
* The data to write to the store.
314314
*/
315-
data: Unmask<TData>;
315+
data: Unmasked<TData>;
316316
/**
317317
* Whether to notify query watchers.
318318
* @defaultValue true

src/core/ApolloClient.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { ApolloLink } from "@apollo/client/link";
1414
import { execute } from "@apollo/client/link";
1515
import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
1616
import type { LocalState } from "@apollo/client/local-state";
17-
import type { MaybeMasked, Unmask } from "@apollo/client/masking";
17+
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
1818
import { DocumentTransform } from "@apollo/client/utilities";
1919
import { __DEV__ } from "@apollo/client/utilities/environment";
2020
import type { VariablesOption } from "@apollo/client/utilities/internal";
@@ -157,19 +157,19 @@ export declare namespace ApolloClient {
157157
> = {
158158
/** {@inheritDoc @apollo/client!MutationOptionsDocumentation#optimisticResponse:member} */
159159
optimisticResponse?:
160-
| Unmask<NoInfer<TData>>
160+
| Unmasked<NoInfer<TData>>
161161
| ((
162162
vars: TVariables,
163163
{ IGNORE }: { IGNORE: IgnoreModifier }
164-
) => Unmask<NoInfer<TData>> | IgnoreModifier);
164+
) => Unmasked<NoInfer<TData>> | IgnoreModifier);
165165

166166
/** {@inheritDoc @apollo/client!MutationOptionsDocumentation#updateQueries:member} */
167167
updateQueries?: MutationQueryReducersMap<TData>;
168168

169169
/** {@inheritDoc @apollo/client!MutationOptionsDocumentation#refetchQueries:member} */
170170
refetchQueries?:
171171
| ((
172-
result: NormalizedExecutionResult<Unmask<TData>>
172+
result: NormalizedExecutionResult<Unmasked<TData>>
173173
) => InternalRefetchQueriesInclude)
174174
| InternalRefetchQueriesInclude;
175175

@@ -517,7 +517,7 @@ export declare namespace ApolloClient {
517517
/**
518518
* The data to write to the store.
519519
*/
520-
data: Unmask<TData>;
520+
data: Unmasked<TData>;
521521
/**
522522
* Whether to notify query watchers.
523523
* @defaultValue true
@@ -579,7 +579,7 @@ export declare namespace ApolloClient {
579579
/**
580580
* The data to write to the store.
581581
*/
582-
data: Unmask<TData>;
582+
data: Unmasked<TData>;
583583
/**
584584
* Whether to notify query watchers.
585585
* @defaultValue true
@@ -1048,7 +1048,7 @@ export class ApolloClient {
10481048
TVariables extends OperationVariables = OperationVariables,
10491049
>(
10501050
options: ApolloClient.ReadQueryOptions<TData, TVariables>
1051-
): Unmask<TData> | null;
1051+
): Unmasked<TData> | null;
10521052

10531053
/**
10541054
* {@inheritDoc @apollo/client!ApolloClient#readQuery:member(1)}
@@ -1066,15 +1066,15 @@ export class ApolloClient {
10661066
* instead of passing it as a separate option.
10671067
*/
10681068
optimistic: boolean
1069-
): Unmask<TData> | null;
1069+
): Unmasked<TData> | null;
10701070

10711071
public readQuery<
10721072
TData = unknown,
10731073
TVariables extends OperationVariables = OperationVariables,
10741074
>(
10751075
options: ApolloClient.ReadQueryOptions<TData, TVariables>,
10761076
optimistic: boolean = false
1077-
): Unmask<TData> | null {
1077+
): Unmasked<TData> | null {
10781078
return this.cache.readQuery<TData, TVariables>(
10791079
{ ...options, query: this.transform(options.query) },
10801080
optimistic
@@ -1154,7 +1154,7 @@ export class ApolloClient {
11541154
TVariables extends OperationVariables = OperationVariables,
11551155
>(
11561156
options: ApolloClient.ReadFragmentOptions<TData, TVariables>
1157-
): Unmask<TData> | null;
1157+
): Unmasked<TData> | null;
11581158
/**
11591159
* {@inheritDoc @apollo/client!ApolloClient#readFragment:member(1)}
11601160
*
@@ -1167,15 +1167,15 @@ export class ApolloClient {
11671167
>(
11681168
options: ApolloClient.ReadFragmentOptions<TData, TVariables>,
11691169
optimistic: boolean
1170-
): Unmask<TData> | null;
1170+
): Unmasked<TData> | null;
11711171

11721172
public readFragment<
11731173
TData = unknown,
11741174
TVariables extends OperationVariables = OperationVariables,
11751175
>(
11761176
options: ApolloClient.ReadFragmentOptions<TData, TVariables>,
11771177
optimistic: boolean = false
1178-
): Unmask<TData> | null {
1178+
): Unmasked<TData> | null {
11791179
return this.cache.readFragment<TData, TVariables>(
11801180
{ ...options, fragment: this.transform(options.fragment) },
11811181
optimistic

src/core/ObservableQuery.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
1212

1313
import type { Cache, MissingFieldError } from "@apollo/client/cache";
1414
import type { MissingTree } from "@apollo/client/cache";
15-
import type { MaybeMasked, Unmask } from "@apollo/client/masking";
15+
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
1616
import type { DeepPartial } from "@apollo/client/utilities";
1717
import { __DEV__ } from "@apollo/client/utilities/environment";
1818
import {
@@ -173,12 +173,12 @@ export declare namespace ObservableQuery {
173173
/** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */
174174
context?: DefaultContext;
175175
updateQuery?: (
176-
previousQueryResult: Unmask<TData>,
176+
previousQueryResult: Unmasked<TData>,
177177
options: {
178-
fetchMoreResult: Unmask<TFetchData>;
178+
fetchMoreResult: Unmasked<TFetchData>;
179179
variables: TFetchVars;
180180
}
181-
) => Unmask<TData>;
181+
) => Unmasked<TData>;
182182
};
183183

184184
export interface SubscribeToMoreOptions<
@@ -924,7 +924,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
924924
cache.writeQuery({
925925
query: combinedOptions.query,
926926
variables: combinedOptions.variables,
927-
data: fetchMoreResult.data as Unmask<any>,
927+
data: fetchMoreResult.data as Unmasked<any>,
928928
});
929929
}
930930
},
@@ -951,8 +951,8 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
951951
// expects that the first argument always contains previous result
952952
// data, but not `undefined`.
953953
const lastResult = this.getCurrentResult();
954-
const data = updateQuery!(lastResult.data as Unmask<TData>, {
955-
fetchMoreResult: fetchMoreResult.data as Unmask<TFetchData>,
954+
const data = updateQuery!(lastResult.data as Unmasked<TData>, {
955+
fetchMoreResult: fetchMoreResult.data as Unmasked<TFetchData>,
956956
variables: combinedOptions.variables as TFetchVars,
957957
});
958958
// was reportResult
@@ -1039,7 +1039,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
10391039
this.updateQuery((previous, updateOptions) =>
10401040
updateQuery(previous, {
10411041
subscriptionData: subscriptionData as {
1042-
data: Unmask<TSubscriptionData>;
1042+
data: Unmasked<TSubscriptionData>;
10431043
},
10441044
...updateOptions,
10451045
})
@@ -1121,7 +1121,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
11211121
const { result, complete } = this.getCacheDiff({ optimistic: false });
11221122

11231123
const newResult = mapFn(
1124-
result! as DeepPartial<Unmask<TData>>,
1124+
result! as DeepPartial<Unmasked<TData>>,
11251125
{
11261126
variables: this.variables,
11271127
complete: !!complete,

src/core/QueryInfo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ApolloCache, Cache } from "@apollo/client/cache";
55
import type { IgnoreModifier } from "@apollo/client/cache";
66
import type { Incremental } from "@apollo/client/incremental";
77
import type { ApolloLink } from "@apollo/client/link";
8-
import type { Unmask } from "@apollo/client/masking";
8+
import type { Unmasked } from "@apollo/client/masking";
99
import type { DeepPartial } from "@apollo/client/utilities";
1010
import {
1111
getOperationName,
@@ -256,7 +256,7 @@ export class QueryInfo<
256256
if (this.shouldWrite(result, variables)) {
257257
cache.writeQuery({
258258
query,
259-
data: result.data as Unmask<any>,
259+
data: result.data as Unmasked<any>,
260260
variables,
261261
overwrite: cacheWriteBehavior === CacheWriteBehavior.OVERWRITE,
262262
});
@@ -341,7 +341,7 @@ export class QueryInfo<
341341
awaitRefetchQueries?: boolean;
342342
refetchQueries?:
343343
| ((
344-
result: NormalizedExecutionResult<Unmask<TData>>
344+
result: NormalizedExecutionResult<Unmasked<TData>>
345345
) => InternalRefetchQueriesInclude)
346346
| InternalRefetchQueriesInclude;
347347
removeOptimistic?: string;
@@ -386,7 +386,7 @@ export class QueryInfo<
386386
({
387387
...result,
388388
dataState: this.hasNext ? "streaming" : "complete",
389-
}) as NormalizedExecutionResult<Unmask<TData>>;
389+
}) as NormalizedExecutionResult<Unmasked<TData>>;
390390

391391
if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
392392
cacheWrites.push({
@@ -498,7 +498,7 @@ export class QueryInfo<
498498
if (!this.hasNext) {
499499
update(
500500
cache as TCache,
501-
result as FormattedExecutionResult<Unmask<TData>>,
501+
result as FormattedExecutionResult<Unmasked<TData>>,
502502
{
503503
context: mutation.context,
504504
variables: mutation.variables,

src/core/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ export {
139139
export type {
140140
DataMasking,
141141
FragmentType,
142-
Mask,
143142
MaybeMasked,
144-
Unmask,
145143
Unmasked,
146144
} from "@apollo/client/masking";
147145

0 commit comments

Comments
 (0)