Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

feature: make a best guess at prettifying object that have no prototype #284

Merged
merged 1 commit into from Jun 15, 2019

Conversation

variousauthors
Copy link
Contributor

@variousauthors variousauthors commented Oct 23, 2018

Hello!

I'm working with a third party library that initializes objects using Object.create(null) (graphql). The result is that these objects do not have prototypes and do not implement toString. This becomes an issue when trying to validate object using your (otherwise wonderful) library.

I have added a line that checks whether a given object implements toString and tries to fall back on JSON.stringify. If stringify encounters the dreaded cyclic structure, then at that point I would say maybe the user needs to rethink things.

I've added two tests to capture this new behaviour. I think that this is not a breaking change. Please let me know if you have any questions or feedback!

For some background on this issue, see discussion here: graphql/express-graphql#177

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 9ae2a1b on variousauthors:master into e913a41 on ansman:master.

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

Successfully merging this pull request may close these issues.

None yet

3 participants