GraphQL: Fragment cycles not allowed

49 Views Asked by At

I need to get full category tree by graphql query. I found information about fragments and I tried to construct query with it:

query getCategories($budgetId: UUID!) {
    categories(budgetId: $budgetId) {
        ...CategoryDetails
    }
}
fragment CategoryDetails on Category {
    id
    name
    description
    visible
    children {
        ...CategoryDetails
    }
}

but I receive that error:

{
    "errors": [
        {
            "message": "Validation error (FragmentCycle@[CategoryDetails]) : Fragment cycles not allowed",
            "locations": [
                {
                    "line": 6,
                    "column": 1
                }
            ],
            "extensions": {
                "classification": "ValidationError"
            }
        }
    ]
}

Do you know how remove this error or any other option to handle tree which could have theoretically infinity nesting level?

Additionaly, maybe usefull I use spring for backend.

0

There are 0 best solutions below