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/graphql number #3461

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
handles integer with valida date format correctly
  • Loading branch information
Khaledgarbaya committed Jan 10, 2018
commit 91ea8a67e7030fe916e074385fc2594bec909940
10 changes: 10 additions & 0 deletions packages/gatsby/src/schema/__tests__/infer-graphql-type-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ describe(`GraphQL type inferance`, () => {
expect(result.data.listNode[0].number).toEqual(1.1)
})

it(`handles integer with valid date format`, async () => {
let result = await queryResult(
[{ number: 2018 }, { number: 1987 }],
`
number
`
)
expect(result.data.listNode[0].number).toEqual(2018)
})

it(`handles date objects`, async () => {
let result = await queryResult(
[
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/infer-graphql-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function inferGraphQLType({
// Check if this is a date.
// All the allowed ISO 8601 date-time formats used.
const momentDate = moment.utc(exampleValue, ISO_8601_FORMAT, true)
if (momentDate.isValid()) {
if (momentDate.isValid() && typeof exampleValue !== `number`) {
return {
type: GraphQLString,
args: {
Expand Down