Skip to content

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