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

fix problem with stringifying date objects #485

Merged
merged 3 commits into from
Dec 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/utils/stringifyVariables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const seen = new Set();

const stringify = (x: any): string => {
if (x && x.toJson) x = x.toJSON();
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this isn’t quite the right check. We could also move it down to avoid the double null check and do a proper typeof being “function” check?

I’m also wondering, what are we really accomplishing for moment here? Don’t we want to convert it and dates to a UTC string?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I recall correctly the normal way for serializing a complex object is through the .toJSON function which is present on most libraries like moment, day-js,...

if (x === undefined) {
return '';
} else if (typeof x == 'number') {
Expand Down