Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using native ES6 Map as much as possible #2664

Closed
IvanGoncharov opened this issue Jun 18, 2020 · 4 comments
Closed

Switch to using native ES6 Map as much as possible #2664

IvanGoncharov opened this issue Jun 18, 2020 · 4 comments

Comments

@IvanGoncharov
Copy link
Member

We need to switch as much as possible ObjMap to Map to prevent bugs like this:

const { buildSchema, graphqlSync } = require('./npmDist');

const schema = buildSchema(`type Query { foo: String }`);
const query = `
  query ($__proto__: Boolean!) {
    __typename
    __typename @skip(if: $__proto__)
  }
`;

const vars = JSON.parse('{ "__proto__": true }');
try {
  console.log(graphqlSync(schema, query, null, null, vars));
} catch (e) {
  console.log(e);
}
@IvanGoncharov IvanGoncharov added this to the 16.0.0-alpha.1 milestone Jun 18, 2020
@markokr
Copy link

markokr commented Jun 18, 2020

AFAIK only Object.create(null) gives proto-less instance, Map objects will have proto by default...

@IvanGoncharov
Copy link
Member Author

@markokr For ES6 Map we would use get/set methods so Map object:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

@markokr
Copy link

markokr commented Jun 19, 2020

Aha, makes sense now.

@IvanGoncharov IvanGoncharov removed this from the 16.0.0-alpha.1 milestone Aug 13, 2020
@PiDelport
Copy link

Using maps instead of Object.create(null) for results would also help avoid the problems described in #484 / #504.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants