gatsby: [gatsby-source-graphql] InputFields (using a scalar type) are invalidated by relay-compiler

Description

It seems that scalar types are not supported? I’ve tried to build the schema via an introspection file as well and it still throws the same error.

Steps to reproduce

  1. Open this simple graphql server and make sure it’s running. See JSON scalar type in edit view. Running queries via graphiql gives you the correct response.

try:

{
  Search {
    asc: by(filter: { sort: "DESC" }) {
      result
    }
    desc: by(filter: { sort: "ASC" }) {
      result
    }
  }
}
  1. Open this gatsby project, which points to the graphql server (step 1) and go to Server Control Panel tab and hit the Restart Sandbox button.

  2. See error in Terminal tab:

error GraphQLIRPrinter: Need an InputObject type to print objects.

Tip

If you change page/index.js with this query (leave out the input args):

export const query = graphql`
  {
    searchapi {
      Search {
        by {
          result
        }
      }
    }
  }
`

the build succeeds… it seems like relay-compiler doesn’t like the custom scalar type. I’ve tried it with an older version of Gatsby and the error was something like:

GraphQL Error Expected a value matching type 'Search_JSON' but got an object value

Expected result

The build should succeed.

Actual result

Error:

error GraphQLIRPrinter: Need an InputObject type to print objects.

Environment

See codesandbox

Using Gatsby’s GraphiQL

Query it with the builtin Gatsby GraphiQL at http://localhost:8000/___graphql works as expected

Thanks so much for creating this awesome project! Keep up the good work.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

@freiksenet any updates on this issue?

It’s a bug upstream. I’ll make a fix and send it to relay-compiler.