Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
It turns out, when some queries are formatted in a particular way,
graphql
will create javascriptObject
's withObject.create(null)
(ref: graphql/graphql-js#504) even though this practice is discouraged (ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create).This causes issues when you try to call prototype builtin's like
hasOwnProperty
on objects created this way.This PR adjusts the linting rule for the
no-prototype-builtins
rule to prevent us from using these builtins to prevent this from causing issues in the future.What changes to the GraphQL/Database Schema does this PR introduce?
None.
How do I test this PR?
Previously, the following GraphQL mutation would return an error:
Now, it does not. The is because the object created in
{url: $url}
is viaObject.create(null)
. Now that we no longer use prototype builtin's, we don't encounter this bug.