Skip to content

Spreading multiple GraphQL fragments into CategoryTree causes Magento to throw #31086

Closed
@griest024

Description

@griest024

Preconditions (*)

  1. Magento 2.4.1 and 2.4-develop

Steps to reproduce (*)

  1. Run the following query:
query GetCategoryTree($filters: CategoryFilterInput!) {
  categoryList(filters: $filters) {
    ...recursiveCategoryNode
  }
}

fragment recursiveCategoryNode on CategoryTree {
  ...categoryNode
  children {
    ...categoryNode
  }
}

fragment categoryNode on CategoryTree {
  id
}

{code}

I used the following argument:
{code:json}

{
    "filters": {
        "ids": {
            "eq": "2"
        }
    }
}

{code}

I did not test on sample data but you can probably infer an analogous argument that matches the sample data. It seems that this only fails when there are categories that match the filter.

Expected result

I expect to get a GraphQL response with category IDs.

Actual result

I get the following response:
{code:json}
{
"errors": [
{
"debugMessage": "Argument 2 passed to Magento\CatalogGraphQl\Model\Category\DepthCalculator::calculate() must be an instance of GraphQL\Language\AST\FieldNode, instance of GraphQL\Language\AST\FragmentSpreadNode given, called in /var/www/html/vendor/magento/module-catalog-graph-ql/Model/Category/DepthCalculator.php on line 41",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"categoryList"
]
}
>,
"data": {
"categoryList": null
}
}
{code}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • < ] 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”.

Note that the following queries do not throw this error and complete as expected:

Using Two Fragments but Not Spreading into Root of recursiveCategoryNode

{code:graphql}
query GetCategoryTree($filters: CategoryFilterInput!) {
categoryList(filters: $filters) {
...recursiveCategoryNode
}
}

fragment recursiveCategoryNode on CategoryTree {
id
children {
...categoryNode
}
}

fragment categoryNode on CategoryTree {
id
}
{code}

and

Spreading into Root but Only Using One Fragment

{code:graphql}
query GetCategoryTree($filters: CategoryFilterInput!) {
categoryList(filters: $filters) {
...categoryNode
children {
...categoryNode
}
}
}

fragment categoryNode on CategoryTree {
id
}

Metadata

Metadata

Assignees

Labels

Component: GraphQLGraphQLFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: 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: doneReported on 2.4.1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions