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 parse numbers as dates in ambiguous cases #3499

Closed
wants to merge 1 commit into from
Closed

Do not parse numbers as dates in ambiguous cases #3499

wants to merge 1 commit into from

Conversation

johnwalley
Copy link
Contributor

I'm using the gatsby-transformer-json plugin to parse a raw JSON string into Javascript objects. Some of the values are numbers but some (not all) are coming through as strings after a GraphQL query.

I believe this is due to them being treated as dates. In particular, a number with four or eight digits is treated as a date if it matched one of the following date formats: YYYY, YYYYMMDD or YYYYMMDD.

This PR removes these date formats from the matching criteria when inferring the GraphQL type. I think this is more in line with what a user would expect and still allows data which is more obviously a date to be parsed as expected.

A number with four or eight digits was treated as a date if it matched one of the following date formats: YYYY, YYYYMMDD or YYYYMMDD
@gatsbybot
Copy link
Collaborator

Deploy preview for gatsbygram ready!

Built with commit 128f76b

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

@KyleAMathews
Copy link
Contributor

Thanks for the PR!

I think you're problem has already been solved though — checkout this PR #3461

Try upgrading to the latest Gatsby and tell us if there's any trouble still!

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