Skip to content

Conversation

nagman
Copy link

@nagman nagman commented Jul 26, 2018

Strangely enough, the .toString() method fires an error in nodejs when the value comes directly from a object transformed by the graphql-yoga package.
Had to replace it with Object.prototype.toString() and now it works.

Strangely enough, the .toString() method fires an error in nodejs when the value comes directly from a object transformed by the graphql-yoga package.
Had to replace it with Object.prototype.toString() and now it works.
@zbitname
Copy link
Member

Directly method calls from prototype are the bad practice.
Maybe your problem has the other resolve.
What the error you receive without your fix? Stacktrace, please :)

If you make a test for this case it will be very cool.

@zbitname zbitname closed this Jul 26, 2018
@zbitname zbitname reopened this Jul 26, 2018
zbitname added 2 commits July 26, 2018 18:21
That's better.
That's better :)
@zbitname
Copy link
Member

zbitname commented Jul 26, 2018

Can you check my fix on your case?
I assume that the value is a kind of data type that is not a !value, but does not have the toString method.

index.js Outdated
*/
function isObject(value) {
return value && value.toString() === '[object Object]';
return value && Object.prototype.toString(value) === '[object Object]';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.prototype.toString() always return [object Object] and it's incorrect.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants