Gatsby: [gatsby-source-graphql] error GraphQLIRPrinter: Need an InputObject type

Created on 26 Mar 2019  Â·  9Comments  Â·  Source: gatsbyjs/gatsby

Description

I'm using gatsby-source-graphql to query data from Hasura backend.

I have a query that works on GraphiQL, but causes gatsby develop to crash.

If I remove order_by from the query, it no longer causes gatsby develop to crash.

Example query:

{
  MyFieldName {
    MyType(
      where: {id: {_eq: "some-id"}}
      order_by: { some_field: asc }
    ) {
      name
    }
  }
}

Expected result

No error.

Actual result

Error message

success update schema — 0.200 s
error GraphQLIRPrinter: Need an InputObject type to print objects.


  Error: Invariant Violation: GraphQLIRPrinter: Need an InputObject type to print objects.

  - invariant.js:40 invariant
    [project]/[fbjs]/lib/invariant.js:40:15

  - GraphQLIRPrinter.js:286 printLiteral
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:286:89

  - GraphQLIRPrinter.js:255 printValue
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:255:12

  - GraphQLIRPrinter.js:224 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:224:24

  - Array.forEach

  - GraphQLIRPrinter.js:223 printArguments
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:223:8

  - GraphQLIRPrinter.js:68 printField
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:68:81

  - GraphQLIRPrinter.js:76 printSelection
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:76:11

  - GraphQLIRPrinter.js:57 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:57:12

  - Array.map

  - GraphQLIRPrinter.js:56 printSelections
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:56:28

  - GraphQLIRPrinter.js:77 printSelection
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:77:12

  - GraphQLIRPrinter.js:57 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:57:12

  - Array.map

  - GraphQLIRPrinter.js:56 printSelections
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:56:28

  - GraphQLIRPrinter.js:38 print
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:38:153

  - Array.map

  - query-compiler.js:196 compilerContext.documents.forEach.node
    [project]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:196:109

  - Array.forEach

  - query-compiler.js:183 
    [project]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:183:35

  - Generator.next


error UNHANDLED REJECTION


  Error: Invariant Violation: GraphQLIRPrinter: Need an InputObject type to print objects.

  - invariant.js:40 invariant
    [project]/[fbjs]/lib/invariant.js:40:15

  - GraphQLIRPrinter.js:286 printLiteral
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:286:89

  - GraphQLIRPrinter.js:255 printValue
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:255:12

  - GraphQLIRPrinter.js:224 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:224:24

  - Array.forEach

  - GraphQLIRPrinter.js:223 printArguments
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:223:8

  - GraphQLIRPrinter.js:68 printField
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:68:81

  - GraphQLIRPrinter.js:76 printSelection
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:76:11

  - GraphQLIRPrinter.js:57 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:57:12

  - Array.map

  - GraphQLIRPrinter.js:56 printSelections
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:56:28

  - GraphQLIRPrinter.js:77 printSelection
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:77:12

  - GraphQLIRPrinter.js:57 
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:57:12

  - Array.map

  - GraphQLIRPrinter.js:56 printSelections
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:56:28

  - GraphQLIRPrinter.js:38 print
    [project]/[@gatsbyjs]/relay-compiler/lib/GraphQLIRPrinter.js:38:153

  - Array.map

  - query-compiler.js:196 compilerContext.documents.forEach.node
    [project]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:196:109

  - Array.forEach

  - query-compiler.js:183 
    [project]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:183:35

  - Generator.next

Environment

(nix) ➜ node_modules/.bin/gatsby info 

  System:
    OS: Linux 4.19 NixOS 18.09.1819.76aafbf4bf4 (Jellyfish) 18.09.1819.76aafbf4bf4 (Jellyfish)
    CPU: x64 Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz
    Shell: 4.4.23 - /nix/store/a9i0a06gcs8w9fj9nghsl0b6vvqpzpi4-bash-4.4-p23/bin/bash
  Binaries:
    Node: 8.11.4 - /nix/store/p0pdd3b6zq3856kw7bcmb1dmy20avfnb-nodejs-8.11.4/bin/node
    Yarn: 1.9.4 - /nix/store/6vzrbn5fy2q39csqmkcl3x5669v5njzn-yarn-1.9.4/bin/yarn
    npm: 5.6.0 - /nix/store/p0pdd3b6zq3856kw7bcmb1dmy20avfnb-nodejs-8.11.4/bin/npm
  Languages:
    Python: 2.7.15 - /nix/store/zr5b2d8hdyf3avsami9nfdmnqr1mvcq5-python-2.7.15/bin/python
  Browsers:
    Firefox: 64.0
  npmPackages:
    gatsby: ^2.1.33 => 2.1.33 
    gatsby-image: ^2.0.33 => 2.0.33 
    gatsby-plugin-manifest: ^2.0.24 => 2.0.24 
    gatsby-plugin-react-helmet: ^3.0.9 => 3.0.9 
    gatsby-plugin-sass: ^2.0.11 => 2.0.11 
    gatsby-plugin-sharp: ^2.0.28 => 2.0.28 
    gatsby-source-filesystem: ^2.0.25 => 2.0.25 
    gatsby-source-graphql: ^2.0.15 => 2.0.15 
    gatsby-transformer-sharp: ^2.1.17 => 2.1.17 
stale? confirmed bug upstream

Most helpful comment

Related to #11710

@freiksenet can you please give an update on this? Thanks in advance!

All 9 comments

Related to #11710

@freiksenet can you please give an update on this? Thanks in advance!

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

Issue is not solved yet

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

I am seeing same issue using WordPress with wp-graphql, I am not able to run a successful query using orderby.

This and related #11710 are closed but unsolved 😞. It's ok with me that it takes some time to solve it, but I would highly appreciate it if the author/contributors of the project at least respond. Seeing a github bot closing the issues due inactivity doesn't feel right to me.

I had similar issue with Strapi (#11161). I could not use where in my query. Issue occurs only when I'm using gatsby-source-graphql, other graphql clients are working fine

So I was able to fix this by using the graphql playground and looking at the type the filter is expecting.

Here is the type I was trying to order by:

image

And here is the query I was executing in the playground:

{
  hasura {
    events_after_a_week(order_by: {event_datetime: asc}) {
      id
      event_datetime
    }
  }
}

In my gatsby code though I had to wrap in brackets for it to work:

{
  hasura {
    events_after_a_week(order_by: [{ event_datetime: asc }]) {
      id
      event_datetime
    }
  }
}

So im not sure if its an schema introspection bug, but this is how I got it working.

Error with your hasura coming from using single query values where arrays are expected.
Probably you copied your query from their playground, but the playground set single objects per default also where array is expected. It doesn't cause errors on playground itself.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  Â·  3Comments

kalinchernev picture kalinchernev  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

dustinhorton picture dustinhorton  Â·  3Comments

hobochild picture hobochild  Â·  3Comments