Skip to content

Commit

Permalink
fix: inversed param values in deepMergeSelectionSetObjects function
Browse files Browse the repository at this point in the history
  • Loading branch information
erickriva committed Dec 19, 2023
1 parent 898d833 commit 5aebe7c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/api-graphql/src/internals/APIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ export function selectionSetIRToString(
return res.join(' ');
}

/**
* Recursively merges selection set objects from `source` onto `target`.
*
* `target` will be updated. `source` will be left alone.
*
* @param source The object to merge into target.
* @param target The object to be mutated.
*/
function deepMergeSelectionSetObjects<T extends Record<string, any>>(
source: T,
target: T
Expand All @@ -490,10 +498,7 @@ function deepMergeSelectionSetObjects<T extends Record<string, any>>(
const sourceValue = source[key];

if (isObject(targetValue) && isObject(sourceValue)) {
target[key] = deepMergeSelectionSetObjects(
Object.assign({}, targetValue),
sourceValue
);
target[key] = deepMergeSelectionSetObjects(sourceValue, targetValue);
} else {
target[key] = sourceValue;

Check warning

Code scanning / CodeQL

Prototype-polluting function Medium

Properties are copied from
source
to
target
without guarding against prototype pollution.
}
Expand Down

0 comments on commit 5aebe7c

Please sign in to comment.