magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

Fragment Results #1027

Closed supernova-at closed 4 years ago

supernova-at commented 4 years ago

Preconditions (*)

Executing against a Magento 2.3.3 backend from a GraphiQL playground instance.

Steps to reproduce (*)

Run the following query that uses a fragment:

fragment ProductDetails on ProductInterface {
  id
  name
}

query productDetail($urlKey: String) {
  products(filter: { url_key: { eq: $urlKey } }) {
    items {
      ... ProductDetails 
    }
  }
}

With the following variables1:

{
  "urlKey": "jillian-top"
}

1 My instance has the Venia sample data installed, so this urlKey is a valid product. Any product urlKey should do here.

Expected result (*)

I expected to see

{
  "data": {
    "products": {
      "items": [
        {
          "id": 1093,
          "name": "Jillian Top"
        }
      ]
    }
  }
}

Actual result (*)

Instead I got

{
  "data": {
    "products": {
      "items": [
        {
          "id": 1093,
          "name": null
        }
      ]
    }
  }
}

Additional Notes

As you can see from the following screenshots, the problem is isolated to using fragments:

Inlining Fields

Screen Shot 2019-10-21 at 9 11 52 AM

Using a Fragment

Screen Shot 2019-10-21 at 9 10 03 AM

These should return the exact same response.

Related Issues

This may be related to https://github.com/magento/graphql-ce/issues/147, but that issue states

Additionally, similar basic fragments will resolve in the products schema.

But this issue shows that not to be the case.