{"action":"created","issue":{"url":"https://api.github.com/repos/graphql/graphql-js/issues/358","repository_url":"https://api.github.com/repos/graphql/graphql-js","labels_url":"https://api.github.com/repos/graphql/graphql-js/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/graphql/graphql-js/issues/358/comments","events_url":"https://api.github.com/repos/graphql/graphql-js/issues/358/events","html_url":"https://github.com/graphql/graphql-js/issues/358","id":148728388,"number":358,"title":"How to define unknown levels of nested fields","user":{"login":"stevehu","id":2042337,"avatar_url":"https://avatars.githubusercontent.com/u/2042337?v=3","gravatar_id":"","url":"https://api.github.com/users/stevehu","html_url":"https://github.com/stevehu","followers_url":"https://api.github.com/users/stevehu/followers","following_url":"https://api.github.com/users/stevehu/following{/other_user}","gists_url":"https://api.github.com/users/stevehu/gists{/gist_id}","starred_url":"https://api.github.com/users/stevehu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevehu/subscriptions","organizations_url":"https://api.github.com/users/stevehu/orgs","repos_url":"https://api.github.com/users/stevehu/repos","events_url":"https://api.github.com/users/stevehu/events{/privacy}","received_events_url":"https://api.github.com/users/stevehu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-15T18:09:31Z","updated_at":"2016-04-15T21:15:33Z","closed_at":null,"body":"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?"},"comment":{"url":"https://api.github.com/repos/graphql/graphql-js/issues/comments/210648852","html_url":"https://github.com/graphql/graphql-js/issues/358#issuecomment-210648852","issue_url":"https://api.github.com/repos/graphql/graphql-js/issues/358","id":210648852,"user":{"login":"robrichard","id":3814096,"avatar_url":"https://avatars.githubusercontent.com/u/3814096?v=3","gravatar_id":"","url":"https://api.github.com/users/robrichard","html_url":"https://github.com/robrichard","followers_url":"https://api.github.com/users/robrichard/followers","following_url":"https://api.github.com/users/robrichard/following{/other_user}","gists_url":"https://api.github.com/users/robrichard/gists{/gist_id}","starred_url":"https://api.github.com/users/robrichard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrichard/subscriptions","organizations_url":"https://api.github.com/users/robrichard/orgs","repos_url":"https://api.github.com/users/robrichard/repos","events_url":"https://api.github.com/users/robrichard/events{/privacy}","received_events_url":"https://api.github.com/users/robrichard/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T21:15:33Z","updated_at":"2016-04-15T21:15:33Z","body":"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.\r\n\r\nImplement fields as a function to allow for the circular dependency.\r\n```js\r\nvar Comment = new GraphQLObjectSchema({\r\n\tname: 'Comment',\r\n\tfields: () => ({\r\n\t\tid: GraphQLString,\r\n\t\tcomments: new GraphQLList(Comment)\r\n\t})\r\n})\r\n```\r\n\r\nLoad three layers of comments for the initial view:\r\n```\r\n{\r\n\tpost(id: 1) {\r\n\t\tcomments {\r\n\t\t\tid\r\n\t\t\tcomments {\r\n\t\t\t\tid\r\n\t\t\t\tcomments {\r\n\t\t\t\t\tid\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nload three more layers when user clicks \"load more comments\"\r\n```\r\n{\r\n\tcomment(id: 2) {\r\n\t\tcomments {\r\n\t\t\tid\r\n\t\t\tcomments {\r\n\t\t\t\tid \r\n\t\t\t\tcomments {\r\n\t\t\t\t\tid\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```"}}