Skip to content

Commit 45e66f1

Browse files
benjieyaacovCR
authored andcommitted
Use Object.create(null) over {} to avoid prototype issues
1 parent d7e040e commit 45e66f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/execution/values.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export function getArgumentValues(
206206
fragmentVariableValues?: Maybe<FragmentVariableValues>,
207207
hideSuggestions?: Maybe<boolean>,
208208
): { [argument: string]: unknown } {
209-
const coercedValues: { [argument: string]: unknown } = {};
209+
const coercedValues: { [argument: string]: unknown } = Object.create(null);
210210

211211
const argumentNodes = node.arguments ?? [];
212212
const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));
@@ -224,7 +224,7 @@ export function getArgumentValues(
224224
hideSuggestions,
225225
);
226226
}
227-
return coercedValues;
227+
return { ...coercedValues };
228228
}
229229

230230
// eslint-disable-next-line max-params

src/utilities/coerceInputValue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function coerceInputValue(
6969
return; // Invalid: intentionally return no value.
7070
}
7171

72-
const coercedValue: any = {};
72+
const coercedValue: any = Object.create(null);
7373
const fieldDefs = type.getFields();
7474
const hasUndefinedField = Object.keys(inputValue).some(
7575
(name) => !Object.hasOwn(fieldDefs, name),
@@ -109,7 +109,7 @@ export function coerceInputValue(
109109
}
110110
}
111111

112-
return coercedValue;
112+
return { ...coercedValue };
113113
}
114114

115115
const leafType = assertLeafType(type);

0 commit comments

Comments
 (0)