Closed lpinca closed 3 years ago
cc: @airhorns
Nice! Do you think it makes sense to set json-bigint
as the defaults since we know that Shopify is gonna return big integers? Make it work by default for users so they don't have to care? Without the defaults, I feel like there will be a stream of sad people who get hit with this very confusing error in production and have to go spelunking to find the issue and the remedy and then set the default to json-bigint
which seems like a bit of wasted effort.
It would change the minimum node version from 10.0
to 10.4
which doesn't seem too bad to me, but I think strictly speaking it'd also be a breaking change since downstream callers might not expect bigints to come back.
but I think strictly speaking it'd also be a breaking change since downstream callers might not expect bigints to come back.
Yes, this is why I prefer to use JSON.parse()
and JSON.stringify()
as defaults and let users use a custom parser/serializer if they need to. It would also be easier for users who wants to experiment with https://github.com/tc39/proposal-json-parse-with-source, without relying on json-bigint
or another dependency.
I've tried to make json-bigint
parse()
and stringify()
the defaults but I hit this bug https://github.com/sidorares/json-bigint/issues/49 for https://github.com/MONEI/Shopify-api-node/blob/3.6.14/test/fixtures/draft-order/res/list.json#L59.
json-bigint
is currently a no go. Do you know any other safe alternative? We can also try to fix that issue but I'm not sure if json-bigint
is actively maintained.
That is a big issue with json-bigint
, yeesh. No go indeed. I don't know of any alternatives which again seems nuts to me that tonnes of people aren't hitting this problem ... but alas. I will see if I can upstream a fix to json-bigint
or dig something else up!
There is also another issue with json-bigint
. If a number has more than 15 digits (including the dot for floats) it will parse it using bignumber.js / BigInt even if it is not needed. For example, there is no need to use bignumber.js for -75.69314750000001 and I expect it to be parsed as a plain JS number.
I think I'll merge this as is and let users deal with these issues themselves.
This is horrifying. The answer to client developers getting silently wrong values is to shrug and say I dunno, we couldn't figure it out, you do it. (But, like, give very little indication that this will be an issue in the docs)
I was just going to move over from doing raw fetch/rest calls but I guess I won't now? The Shopify ecosystem has been a non stop parade of surprises, that's for sure
Fixes: https://github.com/MONEI/Shopify-api-node/issues/500