Retrieving related objects using resolvers
In the previous section, we defined a Teacher type and a Department type. The Teacher type has a Department property of the Department type. When querying the Teacher object, we may also want to retrieve the Department object. How can we do that?
You may think that we can use the Include() method to retrieve the Department object, as follows:
public async Task<List<Teacher>> GetTeachers([Service] AppDbContext context) =>Â Â Â Â await context.Teachers.Include(x => x.Department).ToListAsync();
Then, you can query the Department object as follows:
query{Â Â teachers{
    id
    firstName
    lastName
    department{
      id
      name
      description
    }
  }
}
It does work and you will...