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

Do not override toJSON #257

Closed
steida opened this issue Apr 5, 2020 · 3 comments
Closed

Do not override toJSON #257

steida opened this issue Apr 5, 2020 · 3 comments

Comments

@steida
Copy link

steida commented Apr 5, 2020

It's super confusing that for a given object with some props, JSON.strinfigy produces an object with a different set of props. Also, I really don't see any reason to override toString but that's a minor issue.

It's hard to imagine anyone can use FaunaDB driver with this design. That's not how JavaScript/TypeScript should be written (classes, getters, toJSON/toString overrides). People serialize things all the time. With the current design, it's not even possible to serialize the simple document with Ref.

Related to #256, #222, #254

parseJSON really should not be required. Not at all and definitely not in the browser (I don't want to bundle the whole driver just for parseJSON). Hopefully, this will be addressed with the new TypeScript version.

Btw, if we really need a different type for serialization, for example, Date to a string, io-ts has a concept of Output type for such case. Check https://github.com/gcanti/io-ts-types/blob/master/src/DateFromISOString.ts

@benjumanji
Copy link

benjumanji commented Apr 6, 2020

It's hard to imagine anyone can use FaunaDB driver with this design.

You could have made your entire argument without this. In future please consider this before engaging.

@steida
Copy link
Author

steida commented Apr 6, 2020

@benjitsu It's impossible to use a data library that produces unserializable models.

@benjumanji
Copy link

Evidently it is not, given that we have users today building on top of this driver. Issue closed. Come back when you can offer your technical expertise without the superfluous negativity.

@fauna fauna locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants