Forum Discussion

AishwaryaEA's avatar
2 months ago

Error while fetching products data using graphql query

I am trying to fetch products related data but getting below mentioned error.

Graphql:

query MyQuery {
  products {
    edges {
      node {
        name
        description
        id
      }
    }
  }
}

Error:

{
    "errors": [
        {
            "message": "The field at path '/products' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'ProductConnection' within parent type 'Query'",
            "path": [
                "products"
            ],
            "extensions": {
                "classification": "NullValueInNonNullableField"
            }
        }
    ],
    "data": null
}

Can someone please help me out here ?

Thanks

1 Reply

  • I get the same result running this in the Query Editor. But I don't think there are any products in the test system.. are you able to return product data from a known id? 

    query MyQuery {
      product(id: "id:2") {
        description
      }
    }
    {
      "data": {
        "product": null
      }
    }