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

Graphql infer types gets broken with a mix of float and int #5486

halkeye opened this issue May 20, 2018 · 3 comments

Graphql infer types gets broken with a mix of float and int #5486

halkeye opened this issue May 20, 2018 · 3 comments


Copy link

@halkeye halkeye commented May 20, 2018


As per danoc/gatsby-source-strava-activities#1 I was having isssues with graphql when the results were mixed int and float.

Steps to reproduce

You can use strava-activities and have some activities that have a max speed of a whole number.

I also tracked it down and was able to make a test case

diff --git a/packages/gatsby/src/schema/__tests__/infer-graphql-input-type-test.js b/packages/gatsby/src/schema/__tests__/infer-graphql-input-type-test.js
index 95d9f2b0..e0300c7b 100644
--- a/packages/gatsby/src/schema/__tests__/infer-graphql-input-type-test.js
+++ b/packages/gatsby/src/schema/__tests__/infer-graphql-input-type-test.js
@@ -229,6 +229,16 @@ describe(`GraphQL Input args`, () => {
+  it(`Handles a mix of float and int`, async () => {
+    let fields = inferInputObjectStructureFromNodes({
+      nodes: [
+        { speed: 1 },
+        { speed: 2.1 },
+      ],
+    }).inferredFields
+    expect(fields.speed.type.toString()).toContain(`Float`)
+  })
   it(`Replaces unsupported values in keys`, () => {
     // Add a key with unsupported values to test
     // if they're replaced.

Expected result

Graphql figures out the node field should be a float

Actual result

If the first result is an int, gatsby infers that its an int, not a float


  • Gatsby version (npm list gatsby):
  • gatsby-cli version (gatsby --version):
  • Node.js version:
  • Operating System:
$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.5.1804 (Core) 
Release:        7.5.1804
Codename:       Core

File contents (if changed)

Not applicable so not filling out, but i can
gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

Copy link

@rametta rametta commented May 28, 2018

i also have the same problem

Copy link

@ds300 ds300 commented May 31, 2018

I'm also suffering from this particular problem. More discussion of the wider issue: #3344

Copy link

@pieh pieh commented Jun 1, 2018

PR with fix if anyone would like to track it - #5654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants