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

Infer value of date objects fixes #1952 #1964

Merged
merged 4 commits into from
Aug 30, 2017
Merged

Conversation

KyleAMathews
Copy link
Contributor

No description provided.

@KyleAMathews
Copy link
Contributor Author

@jquense seem reasonable?

@gatsbybot
Copy link
Collaborator

gatsbybot commented Aug 30, 2017

Deploy preview ready!

Built with commit 4def48c

https://deploy-preview-1964--gatsbygram.netlify.com

@@ -18,6 +18,8 @@ const areAllSameType = list =>
const isEmptyObjectOrArray = (obj: any): boolean => {
if (obj === INVALID_VALUE) {
return true
} else if (_.isDate(obj)) {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

does the below branch not catch this already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's reported as an empty object

Copy link
Contributor

Choose a reason for hiding this comment

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

weeiiiird

@@ -129,7 +129,7 @@ function inferGraphQLType({
},
},
resolve(object, { fromNow, difference, formatString }) {
const date = object[fieldName]
const date = object[fieldName].toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

does toISOString() make more sense as a default? its a bit less culture dependent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh for sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to do JSON.parse(JSON.stringify(date)) as date could just be a string so this seemed simplest. The internets say that JSON.stringify uses Date.toISOString under the hood anyways.

@KyleAMathews
Copy link
Contributor Author

Deploy preview failed.

Built with commit 4def48c

https://app.netlify.com/sites/using-glamor/deploys/59a63d61cf321c54a9547048

@KyleAMathews KyleAMathews merged commit aab0fe4 into master Aug 30, 2017
@KyleAMathews
Copy link
Contributor Author

Yeah! Travis is back to green!

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.

3 participants