Skip to content

Commit

Permalink
[Data masking] Ensure @unmask can be used with the fragment registry (
Browse files Browse the repository at this point in the history
#12029)

Co-authored-by: Lenz Weber-Tronic <[email protected]>
  • Loading branch information
jerelmiller and phryneas authored Aug 28, 2024
1 parent 120ace4 commit a5ef5a8
Show file tree
Hide file tree
Showing 24 changed files with 558 additions and 507 deletions.
17 changes: 5 additions & 12 deletions .api-reports/api-report-cache.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
abstract evict(options: Cache_2.EvictOptions): boolean;
abstract extract(optimistic?: boolean): TSerialized;
// (undocumented)
protected fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(): string[];
// Warning: (ae-forgotten-export) The symbol "getApolloCacheMemoryInternals" needs to be exported by the entry point index.d.ts
Expand All @@ -40,9 +40,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// (undocumented)
maskOperation<TData = unknown>(document: DocumentNode, data: TData): TData;
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// (undocumented)
Expand Down Expand Up @@ -583,7 +581,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
// (undocumented)
extract(optimistic?: boolean): NormalizedCacheObject;
// (undocumented)
protected fragmentMatches(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(options?: {
resetResultCache?: boolean;
Expand All @@ -596,6 +594,8 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// (undocumented)
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
readonly makeVar: typeof makeVar;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
Expand Down Expand Up @@ -704,13 +704,6 @@ export function makeReference(id: string): Reference;
// @public (undocumented)
export function makeVar<T>(value: T): ReactiveVar<T>;

// @public (undocumented)
export interface MaskFragmentOptions<TData> {
data: TData;
fragment: DocumentNode | TypedDocumentNode<TData>;
fragmentName?: string;
}

// @public (undocumented)
export interface MergeInfo {
// (undocumented)
Expand Down
35 changes: 25 additions & 10 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
abstract evict(options: Cache_2.EvictOptions): boolean;
abstract extract(optimistic?: boolean): TSerialized;
// (undocumented)
protected fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(): string[];
// Warning: (ae-forgotten-export) The symbol "getApolloCacheMemoryInternals" needs to be exported by the entry point index.d.ts
Expand All @@ -54,12 +54,8 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
getMemoryInternals?: typeof getApolloCacheMemoryInternals;
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// (undocumented)
maskOperation<TData = unknown>(document: DocumentNode, data: TData): TData;
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// (undocumented)
Expand Down Expand Up @@ -1113,7 +1109,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
// (undocumented)
extract(optimistic?: boolean): NormalizedCacheObject;
// (undocumented)
protected fragmentMatches(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(options?: {
resetResultCache?: boolean;
Expand All @@ -1126,6 +1122,8 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// (undocumented)
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
readonly makeVar: typeof makeVar;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
Expand Down Expand Up @@ -1317,11 +1315,22 @@ export function makeVar<T>(value: T): ReactiveVar<T>;

// @public (undocumented)
interface MaskFragmentOptions<TData> {
// (undocumented)
data: TData;
fragment: DocumentNode | TypedDocumentNode<TData>;
// (undocumented)
fragment: DocumentNode;
// (undocumented)
fragmentName?: string;
}

// @public (undocumented)
interface MaskOperationOptions<TData> {
// (undocumented)
data: TData;
// (undocumented)
document: DocumentNode;
}

// @public (undocumented)
type MaybeAsync<T> = T | PromiseLike<T>;

Expand Down Expand Up @@ -1857,8 +1866,14 @@ class QueryManager<TStore> {
onQueryUpdated?: OnQueryUpdated<any>;
keepRootFields?: boolean;
}, cache?: ApolloCache<TStore>): Promise<FetchResult<TData>>;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// Warning: (ae-forgotten-export) The symbol "MaskOperationOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskOperation<TData = unknown>(options: MaskOperationOptions<TData>): TData;
// (undocumented)
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache<any>>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<TData>>;
// (undocumented)
Expand Down Expand Up @@ -2343,8 +2358,8 @@ interface WriteContext extends ReadMergeModifyContext {
// src/cache/inmemory/types.ts:139:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:116:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:117:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:144:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:389:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:152:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:397:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:275:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/link/http/selectHttpOptionsAndBody.ts:128:32 - (ae-forgotten-export) The symbol "HttpQueryOptions" needs to be exported by the entry point index.d.ts

Expand Down
31 changes: 22 additions & 9 deletions .api-reports/api-report-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class ApolloCache<TSerialized> implements DataProxy {
abstract evict(options: Cache_2.EvictOptions): boolean;
abstract extract(optimistic?: boolean): TSerialized;
// (undocumented)
protected fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(): string[];
// Warning: (ae-forgotten-export) The symbol "getApolloCacheMemoryInternals" needs to be exported by the entry point index.d.ts
Expand All @@ -52,12 +52,8 @@ abstract class ApolloCache<TSerialized> implements DataProxy {
//
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// (undocumented)
maskOperation<TData = unknown>(document: DocumentNode, data: TData): TData;
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// Warning: (ae-forgotten-export) The symbol "Transaction" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -1074,11 +1070,22 @@ type LocalStateOptions<TCacheShape> = {

// @public (undocumented)
interface MaskFragmentOptions<TData> {
// (undocumented)
data: TData;
fragment: DocumentNode | TypedDocumentNode<TData>;
// (undocumented)
fragment: DocumentNode;
// (undocumented)
fragmentName?: string;
}

// @public (undocumented)
interface MaskOperationOptions<TData> {
// (undocumented)
data: TData;
// (undocumented)
document: DocumentNode;
}

// @public (undocumented)
type MaybeAsync<T> = T | PromiseLike<T>;

Expand Down Expand Up @@ -1635,8 +1642,14 @@ class QueryManager<TStore> {
onQueryUpdated?: OnQueryUpdated<any>;
keepRootFields?: boolean;
}, cache?: ApolloCache<TStore>): Promise<FetchResult<TData>>;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// Warning: (ae-forgotten-export) The symbol "MaskOperationOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskOperation<TData = unknown>(options: MaskOperationOptions<TData>): TData;
// (undocumented)
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache<any>>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<TData>>;
// (undocumented)
Expand Down Expand Up @@ -2367,8 +2380,8 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:116:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:117:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:144:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:389:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:152:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:397:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:174:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:203:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:275:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
Expand Down
31 changes: 22 additions & 9 deletions .api-reports/api-report-react_components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class ApolloCache<TSerialized> implements DataProxy {
abstract evict(options: Cache_2.EvictOptions): boolean;
abstract extract(optimistic?: boolean): TSerialized;
// (undocumented)
protected fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
fragmentMatches?(fragment: InlineFragmentNode, typename: string): boolean;
// (undocumented)
gc(): string[];
// Warning: (ae-forgotten-export) The symbol "getApolloCacheMemoryInternals" needs to be exported by the entry point index.d.ts
Expand All @@ -52,12 +52,8 @@ abstract class ApolloCache<TSerialized> implements DataProxy {
//
// (undocumented)
identify(object: StoreObject | Reference): string | undefined;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// (undocumented)
maskOperation<TData = unknown>(document: DocumentNode, data: TData): TData;
lookupFragment(fragmentName: string): FragmentDefinitionNode | null;
// (undocumented)
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// Warning: (ae-forgotten-export) The symbol "Transaction" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -935,11 +931,22 @@ type LocalStateOptions<TCacheShape> = {

// @public (undocumented)
interface MaskFragmentOptions<TData> {
// (undocumented)
data: TData;
fragment: DocumentNode | TypedDocumentNode<TData>;
// (undocumented)
fragment: DocumentNode;
// (undocumented)
fragmentName?: string;
}

// @public (undocumented)
interface MaskOperationOptions<TData> {
// (undocumented)
data: TData;
// (undocumented)
document: DocumentNode;
}

// @public (undocumented)
type MaybeAsync<T> = T | PromiseLike<T>;

Expand Down Expand Up @@ -1449,8 +1456,14 @@ class QueryManager<TStore> {
onQueryUpdated?: OnQueryUpdated<any>;
keepRootFields?: boolean;
}, cache?: ApolloCache<TStore>): Promise<FetchResult<TData>>;
// Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
// Warning: (ae-forgotten-export) The symbol "MaskOperationOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maskOperation<TData = unknown>(options: MaskOperationOptions<TData>): TData;
// (undocumented)
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache<any>>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<TData>>;
// (undocumented)
Expand Down Expand Up @@ -1846,8 +1859,8 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:116:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:117:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:144:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:389:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:152:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:397:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:174:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:203:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:275:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
Expand Down
Loading

0 comments on commit a5ef5a8

Please sign in to comment.