1

I am very new to GraphQl Magento. When I access the graphql url in my installation, following the below tutorial, it throws the below error. https://devdocs.magento.com/guides/v2.3/graphql/

Do I need to enable any modules, or set any configurations?

{
  "errors": [
    {
      "message": "Syntax Error: Unexpected <EOF>",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 4,
          "column": 35
        }
      ]
    }
  ]
}
4

I have this error too when i hit the graphql endpoint in my browser. After a debug attempt, it appears graphql expects a query to be passed. (the function to debug is \Magento\GraphQl\Controller\GraphQl::dispatch)

The quick way to get graphql running with examples you find around is to install GraphiQL, then a basic query that works at my end is:

  {
        cmsPage(identifier: "no-route") {
        url_key
        title
        content
        content_heading
        page_layout
        meta_title
        meta_description
        meta_keywords
      }
    }

For completeness, I have also tested Postman and I have it now working too (with more work than GraphiQL) by setting the following:

Header field Content-Type to be application/json Method to be POST

0

Another possible error might be because your endpoint is getting redirected and dropping the $_POST data.

Easy debug, just add to your index.php (might be the one in the /pub directory): var_dump($_POST) and try your query again. If the response comes back with an empty string, you know that your issue is that the body of the query is not getting passed to the Magento application.

Make sure the request is a POST and is going the secure_url of the website

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.