From 128f76be12b3a9fee8219226acef17313b927c4e Mon Sep 17 00:00:00 2001 From: johnwalley Date: Thu, 11 Jan 2018 23:35:48 +0000 Subject: [PATCH] Do not parse numbers as dates 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 --- .../__tests__/__snapshots__/infer-graphql-type-test.js.snap | 2 +- .../gatsby/src/schema/__tests__/infer-graphql-type-test.js | 2 +- packages/gatsby/src/schema/infer-graphql-type.js | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/gatsby/src/schema/__tests__/__snapshots__/infer-graphql-type-test.js.snap b/packages/gatsby/src/schema/__tests__/__snapshots__/infer-graphql-type-test.js.snap index 9fb28ffd45b81..7960f21cdeebd 100644 --- a/packages/gatsby/src/schema/__tests__/__snapshots__/infer-graphql-type-test.js.snap +++ b/packages/gatsby/src/schema/__tests__/__snapshots__/infer-graphql-type-test.js.snap @@ -109,7 +109,7 @@ Object { "date": "1984", "title": "The world of slash and adventure", }, - "hair": 2, + "hair": 2048, }, ], }, diff --git a/packages/gatsby/src/schema/__tests__/infer-graphql-type-test.js b/packages/gatsby/src/schema/__tests__/infer-graphql-type-test.js index 5952717c8b847..da668ad3484b1 100644 --- a/packages/gatsby/src/schema/__tests__/infer-graphql-type-test.js +++ b/packages/gatsby/src/schema/__tests__/infer-graphql-type-test.js @@ -81,7 +81,7 @@ describe(`GraphQL type inferance`, () => { id: `boo`, name: `The Mad Wax`, type: `Test`, - hair: 2, + hair: 2048, date: `1984-10-12`, anArray: [1, 2, 5, 4], aNestedArray: [[1, 2, 3, 4]], diff --git a/packages/gatsby/src/schema/infer-graphql-type.js b/packages/gatsby/src/schema/infer-graphql-type.js index 40e5a5fd05ece..5ed478a9efb0d 100644 --- a/packages/gatsby/src/schema/infer-graphql-type.js +++ b/packages/gatsby/src/schema/infer-graphql-type.js @@ -43,10 +43,8 @@ export type ProcessedNodeType = { } const ISO_8601_FORMAT = [ - `YYYY`, `YYYY-MM`, `YYYY-MM-DD`, - `YYYYMMDD`, `YYYY-MM-DDTHHZ`, `YYYY-MM-DDTHH:mmZ`, `YYYY-MM-DDTHHmmZ`, @@ -59,7 +57,6 @@ const ISO_8601_FORMAT = [ `YYYY-[W]WW-E`, `YYYY[W]WWE`, `YYYY-DDDD`, - `YYYYDDDD`, ] function inferGraphQLType({