Skip to content

Commit f320fd0

Browse files
committed
Use null-prototype objects as string maps
1 parent 1b639e3 commit f320fd0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/execution/execute.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function buildExecutionContext(
165165
): ExecutionContext {
166166
const errors: Array<GraphQLError> = [];
167167
let operation: ?OperationDefinition;
168-
const fragments: {[name: string]: FragmentDefinition} = {};
168+
const fragments: {[name: string]: FragmentDefinition} = Object.create(null);
169169
documentAST.definitions.forEach(definition => {
170170
switch (definition.kind) {
171171
case Kind.OPERATION_DEFINITION:
@@ -218,8 +218,8 @@ function executeOperation(
218218
exeContext,
219219
type,
220220
operation.selectionSet,
221-
{},
222-
{}
221+
Object.create(null),
222+
Object.create(null)
223223
);
224224

225225
if (operation.operation === 'mutation') {
@@ -329,7 +329,7 @@ function executeFields(
329329
}
330330
return results;
331331
},
332-
{}
332+
Object.create(null)
333333
);
334334

335335
// If there are no promises, we can just return the object
@@ -486,7 +486,7 @@ function promiseForObject<T>(
486486
values => values.reduce((resolvedObject, value, i) => {
487487
resolvedObject[keys[i]] = value;
488488
return resolvedObject;
489-
}, {})
489+
}, Object.create(null))
490490
);
491491
}
492492

@@ -757,8 +757,8 @@ function completeValue(
757757
}
758758

759759
// Collect sub-fields to execute to complete this value.
760-
let subFieldASTs = {};
761-
const visitedFragmentNames = {};
760+
let subFieldASTs = Object.create(null);
761+
const visitedFragmentNames = Object.create(null);
762762
for (let i = 0; i < fieldASTs.length; i++) {
763763
const selectionSet = fieldASTs[i].selectionSet;
764764
if (selectionSet) {

0 commit comments

Comments
 (0)