-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to define unknown levels of nested fields #358
Comments
I don't think there is, at least not in GraphQL. I think the best way to get the same result is to turn the comments tree into a list via a preorder-traversal. The comment should have an additional field called level (or something like that), which will tell the client how to display it. |
I think you could do this by having each comment have a field to get child comments. You could write a query to get as many nested levels as you need for the initial read. I'm imagining a system like reddit where you can view x number of nested comments, then click a link to view more past that. Implement fields as a function to allow for the circular dependency. var Comment = new GraphQLObjectSchema({
name: 'Comment',
fields: () => ({
id: GraphQLString,
comments: new GraphQLList(Comment)
})
}) Load three layers of comments for the initial view:
load three more layers when user clicks "load more comments"
|
It was discussed here and the case was closed. |
For a multi-level comment system, you have reply of reply and the depth is different for each comment. In the spec, it looks like you have to define the exact structure of data you want to be returned; however, when you load a list of comments, you don't know if one of them have 10 levels of replies. Is there a way to workaround the current spec or the spec can be extended to support it?
The text was updated successfully, but these errors were encountered: