graphql icon indicating copy to clipboard operation
graphql copied to clipboard

GraphQL does not report parsing errors

Open drewwells opened this issue 5 years ago • 2 comments

I see this useless message reported in many situations: Cannot query field "{some field}" on type "RootQuery".

There's actual errors underneath that are not being reported. FieldsOnCorrectTypeRule is reporting graphql errors but none of these are surfaced to the caller.

gqlerrors.FormattedError{Message:"Oracle fields must be an object with field names as keys or a function which return such an object."

While these are server errors and not actionable by the client, they should at least be logged when encountered.

drewwells avatar Feb 08 '21 03:02 drewwells

The actual error was this

var oracleType = graphql.NewObject(graphql.ObjectConfig{                                       
    Name: "Oracle",
    Fields: &graphql.Fields{}
}

Error goes away when changed to this

var oracleType = graphql.NewObject(graphql.ObjectConfig{                                      
    Name: "Oracle",
    Fields: graphql.Fields{}
}

drewwells avatar Feb 08 '21 04:02 drewwells

I had an error similar to this. But it was caused by the name of the object. Works well

var UserType = graphql.NewObject(graphql.ObjectConfig{
	Name: "User",
	Fields: graphql.Fields{}
})

Does not work.

var UserType = graphql.NewObject(graphql.ObjectConfig{
	Name: "User type",
	Fields: graphql.Fields{}
})

Eventually, this type breaks the mutation in my case.

{
  "data": null,
  "errors": [
    {
      "message": "Cannot query field \"createUser\" on type \"RootMutation\".",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}

IFtech-A avatar Aug 01 '21 04:08 IFtech-A