The resolver returns only what you make it return. It's not automatically generated based on the types. What it does is: it matched the types of the object according to what you make it resolve.
In this case your resolver would return a list of users, and each user has a name and a list of posts, and each post has a title, body and an author.
And yes, it seems that it can create an infinite data stream, but that's exactly the idea behind graph, is that all the data is connected to it's relations and vice-versa.
You can imagine the return data something like this:
data: {
users: [
{
name: "user 1",
posts: [
{
title: "post 1",
body: "post body",
author: {
name: "user 1",
posts: [
{
title: "post 1",
body: "post body",
author: {
name: "user 1",
posts: [
{
.....
}
]
}
}
]
}
}
]
},
{
name: "user 2",
posts: [
{
title: "post 2",
body: "post body",
author: {
name: "user 2",
posts: [
{
title: "post 2",
body: "post body",
author: {
name: "user 2",
posts: [
{
.....
}
]
}
}
]
}
}
]
}
]
}
And again, GraphQL only returns the data you ask it to return. So, if you only want users and posts the query would be something like:
query getUsers {
users {
name
posts {
title
body
}
}
}
In this case it would only return the users and their posts, not the authors.