Skip to content

Commit

Permalink
Bring cloneDeep back
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoomBringer committed Oct 31, 2022
1 parent b335697 commit d42ee1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
makeUniqueId,
isDocumentNode,
isNonNullObject,
cloneDeep,
} from '../utilities';
import { ApolloError, isApolloError } from '../errors';
import {
Expand Down Expand Up @@ -1037,6 +1038,10 @@ export class QueryManager<TStore> {
): Observable<ApolloQueryResult<TData>> {
const requestId = queryInfo.lastRequestId = this.generateRequestId();

// Make sure we write the result below using the same options we were given,
// even though the input object may have been modified in the meantime.
options = cloneDeep(options);

// Performing transformForLink here gives this.cache a chance to fill in
// missing fragment definitions (for example) before sending this document
// through the link chain.
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/common/cloneDeep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function cloneDeepHelper<T>(val: T, seen?: Map<any, any>): T {
// possible in all JS environments, so we will assume they exist/work.
const copy = Object.create(Object.getPrototypeOf(val));
seen.set(val, copy);
Object.keys(val).forEach(key => {
Object.keys(val).concat(Object.getOwnPropertySymbols(val) as any).forEach(key => {
copy[key] = cloneDeepHelper((val as any)[key], seen);
});
return copy;
Expand Down

0 comments on commit d42ee1b

Please sign in to comment.