-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Missing Object Prototype #484
Comments
Can you explain more about what code is producing the error: "Uncaught TypeError: Cannot convert object to primitive value"? That on its own seems suspect. Object's prototype method for converting to a primitive returns The missing prototype isn't a bug, it's an intentional tradeoff. Imagine what would be produced by the query: query {
toString: me { name }
valueOf: someOtherRealField
} Those aliases would cause those properties to be set on the resulting object. If the resulting object was expected to have ObjectPrototype with toString and valueOf prototype methods, then setting those properties would render them inaccessible - if you rely on them then your code would break. A clever malicious person might try to do this to break your server. |
yeah @leebyron, i waited to hear your thoughts about this before going and fixing it, the error itself were coming as an issue report to graphql-tools, @patotoma can you please elaborate on this? |
Sorry for the delayed response. I'm glad you jumped in. The server doesn't need to define them as fields, a query can just use aliases to create that scenario |
Aliases? Cool! Do you have an example for alias? Didnt know this feature.. |
You can read more about them here: http://graphql.org/learn/queries/#aliases |
Thanks! |
another Month without patotoma response.. so im gonna close it. Thanks lee! |
Is it possible to have Some libraries use instanceof to check the type of arguments and this prevents them from functioning correctly. If a query had an object with a type 'toString' surely the toString method is simply overwritten and so there is no problem, this seems like a better solution though I haven't thought about it that much. |
This primarily intended to work around the problem of graphql-js using null prototype objects to represent maps. See: graphql/graphql-js#484 and related (This code is a bit ridiculous in implementation, but it lets callers deal with a simpler interface.)
This primarily intended to work around the problem of graphql-js using null prototype objects to represent maps. See: graphql/graphql-js#484 and related (This code is a bit ridiculous in implementation, but it lets callers deal with a simpler interface.)
This primarily intended to work around the problem of graphql-js using null prototype objects to represent maps. See: graphql/graphql-js#484 and related (This code is a bit ridiculous in implementation, but it lets callers deal with a simpler interface.)
This primarily intended to work around the problem of graphql-js using null prototype objects to represent maps. See: graphql/graphql-js#484 and related (This code is a bit ridiculous in implementation, but it lets callers deal with a simpler interface.)
Hi,
GraphQL response object is missing Javascript's prototype property,
This is causing errors like:
Uncaught TypeError: Cannot convert object to primitive value
for example (res.data.user):
Here is a small test shows it
this is continuation of ardatan/graphql-tools#127
The text was updated successfully, but these errors were encountered: