Mix phx.server localhost: error 4000 SyntaxError

When I run my elixir graphql api project, it goes to the server without error, but why am I not getting any response when entering the data?

{
  book(id: 1){
    position           
  }
}

Error typing id

SyntaxError: Unexpected token < in JSON at position 0

{
  book{
    position
  }
}

error when not typing id

{
  "errors": [
    {
      "locations": [
        {
          "column": 3,
          "line": 2
        }
      ],
      "message": "In argument \"id\": Expected type \"Int!\", found null."
    }
  ]
}


usually happens when the server is returning an html page not json, probably some error page specially if it is development mode, check the network tab on chrome console if there is the raw body, it can give more clues to us in helping you!

1 Like

This means an error is happening in your server. Check your server logs for the error.