Skip to content

Commit

Permalink
Add prefix to operation id in maskOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Nov 13, 2024
1 parent 81c14b3 commit 3c8b82b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
>(
options: SubscriptionOptions<TVariables, T>
): Observable<FetchResult<MaybeMasked<T>>> {
const id = `s${this.queryManager.generateQueryId()}`;
const id = this.queryManager.generateQueryId();

return this.queryManager
.startGraphQLSubscription<T>(options)
Expand Down
12 changes: 5 additions & 7 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,23 +1574,21 @@ export class QueryManager<TStore> {

if (__DEV__) {
const { fetchPolicy, id } = options;
const operationType = getOperationDefinition(document)?.operation;
const operationId = (operationType?.[0] ?? "o") + id;

if (
this.dataMasking &&
fetchPolicy === "no-cache" &&
!isFullyUnmaskedOperation(document) &&
(!id || !this.noCacheWarningsByQueryId.has(id))
!this.noCacheWarningsByQueryId.has(operationId)
) {
if (id) {
this.noCacheWarningsByQueryId.add(id);
}
this.noCacheWarningsByQueryId.add(operationId);

invariant.warn(
'[%s]: Fragments masked by data masking are inaccessible when using fetch policy "no-cache". Please add `@unmask` to each fragment spread to access the data.',
getOperationName(document) ??
`Unnamed ${
getOperationDefinition(document)?.operation ?? "operation"
}`
`Unnamed ${operationType ?? "operation"}`
);
}
}
Expand Down

0 comments on commit 3c8b82b

Please sign in to comment.