Skip to content

Category fields missing data when in deeply (>1) nested GraphQL fragments #38863

Open
@griest024

Description

@griest024

Preconditions and environment

Magento version: 2.4.6-p6

Steps to reproduce

Send a GraphQL request with the following query:

query MagentoGetCategoryTree($filters: CategoryFilterInput!) {
    categoryList(filters: $filters) {
      ...depth0
      children {
        uid
      }
    __typename
  }
}
fragment depth0 on CategoryTree {
    ...depth1
  __typename
}
fragment depth1 on CategoryTree {
  ...depth2
  name
  __typename
}
fragment depth2 on CategoryTree {
    name
    uid
  __typename
}

and the following variables:

{
    "filters":{"ids":{"eq":"4"}}
}

Expected result

{
    "data": {
        "categoryList": [
            {
                "name": "Bags",
                "uid": "NA==",
                "__typename": "CategoryTree",
                "children": []
            }
        ]
    }
}

Actual result

{
    "data": {
        "categoryList": [
            {
                "name": null,
                "uid": "NA==",
                "__typename": "CategoryTree",
                "children": []
            }
        ]
    }
}

Additional information

This is almost certainly related to #31086.

Any of the following causes name to be filled with the correct data:

  • Moving the name field selection to the depth0 fragment:
query MagentoGetCategoryTree($filters: CategoryFilterInput!) {
    categoryList(filters: $filters) {
      ...depth0
      children {
        uid
      }
    __typename
  }
}
fragment depth0 on CategoryTree {
    ...depth1
    name
  __typename
}
...
  • Moving the name field selection to the body of the query:
query MagentoGetCategoryTree($filters: CategoryFilterInput!) {
    categoryList(filters: $filters) {
      ...depth0
      name
      children {
        uid
      }
    __typename
  }
}
...
  • Adding name to the selection set of the children (why?????):
query MagentoGetCategoryTree($filters: CategoryFilterInput!) {
    categoryList(filters: $filters) {
      ...depth0
      children {
        name
      }
    __typename
  }
}

Its interesting that some fields can be selected in deeply nested fragments, such as uid. The following query gives the correct value for uid:

query MagentoGetCategoryTree($filters: CategoryFilterInput!) {
    categoryList(filters: $filters) {
      ...depth0
    __typename
  }
}
fragment depth0 on CategoryTree {
    ...depth1
}
fragment depth1 on CategoryTree {
  ...depth2
}
fragment depth2 on CategoryTree {
  ...depth3
}
fragment depth3 on CategoryTree {
  ...depth4
}
fragment depth4 on CategoryTree {
  ...depth5
}
fragment depth5 on CategoryTree {
  ...depth6
}
fragment depth6 on CategoryTree {
  ...depth7
}
fragment depth7 on CategoryTree {
    uid
}

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: APIsComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressReported on 2.4.6-p6Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions