When no resolver has been specified for a field, by default, this field will take on the value of the property in the object that's been resolved by the parent – that is, if that object has a property name that matches the field name. So, the fields in the Planet object type can be refactored as follows:
fields: {
id: { type: graphql.GraphQLInt },
name: { type: graphql.GraphQLString },
age: { type: graphql.GraphQLString },
population: { type: graphql.GraphQLString },
}
The values of these fields will fall back to the properties in the object that's been resolved by the parent (the query type) under the hood, as follows:
root.id
root.name
root.age
root.population
So, put the other way around, when a resolver is specified explicitly for a field, this resolver will always be used, even if the parent's resolver returns any value for that field. For example, let's specify a value explicitly for the id field in the Planet...