GraphQL doesn't allow for recursive types. This limitation cropped up in a project and was a frustrating (re)discovery. You have to pick a maximum depth and explicitly define that depth. It abuses POST. No way to tell by a quick glance at the network tab the purpose of a request. Whichever team controls the implementation of the resolvers decides the return structure which may be less than ideal for the front end tea…
> GraphQL doesn't allow for recursive types. It does, this schema works: type Item { id: ID! children: [Item!]! } type Query { root: Item! } GraphQL queries describe the shape of the response, so with this schema it's not possible to ask recursively for "the full tree up to an arbitrary depth". One way to solve this would be to add a "descendants" field that returns a list of all the children, grand-children...
IE:
fragment CategoriesRecursive on Category {
subcategories {
...SubcategoryFields
subcategories {
...SubcategoryFields
subcategories {
...SubcategoryFields
}
}
}
}
So you have to build your schema with a maximum supported depth. This is not infinitely recursive which is a limitation of the GQL type system.