Looking through the example Meteor apps (in this case, @abhiaiyer shopping cart) in the Apollo docs and came across two resolver parameters I’m unclear on. The parameters are root and _ as seen in the following links, respectively:
source is the object returned from the parent resolver, which I ended up calling root in my code (I should probably fix it to match the official docs).
args is the args passed to the field in the query, like todos(completed: true) will result in { completed: true }.
context is something you can set on a per-request basis.
info is passed in by the GraphQL execution engine, and includes stuff like the full query.
So to answer your question directly, root in our code is referring to the result from the parent resolver, so if you have:
{
todoList(id: "5") {
todoCount
}
}
Then the first argument to the todoCount resolver is the todo list object returned from the todoList resolver.
_ is often used as a convention for unused arguments. Since GraphQL-JS uses sequential arguments instead of keyword arguments, there is no way to only get the arguments you want. So when I don’t use args, I just replace that argument with a _ to show that it’s unused.
I think this is some great feedback about how we can make our example apps clearer.