website/src/blog/2018-09-02-hot-chocolate-0.4.5.md
With version 0.4.5 we closed a lot of spec gaps and refined the schema configuration API.
We now are finished with implementing the query validation rules. The following rules were added since version 0.4.0:
We now also support the @deprecated directive when using schema-first.
Furthermore, we fixed a lot of bugs around schema-first. So, at the moment code-first is still the most viable way to create a schema,but we are working hard to get both flavours on par.
Apart from that we now allow for non-terminating errors within a field-resolver.
public IEnumerable<ICharacter> GetCharacter(string[] characterIds, IResolverContext context)
{
foreach (string characterId in characterIds)
{
ICharacter character = _repository.GetCharacter(characterId);
if (character == null)
{
context.ReportError(
"Could not resolve a character for the " +
$"character-id {characterId}.");
}
else
{
yield return character;
}
}
}
If you want to share resolver logic between types in your schema you can now do that with shared resolvers which can be bound to fields:
public class PersonResolvers
{
public Task<IEnumerable<Person>> GetFriends(Person person, [Service]IPersonRepository repository)
{
return repository.GetFriendsAsync(person.FriendIds);
}
}
public class PersonType : ObjectType<Person>
{
protected override void Configure(IObjectDescriptor<Person> desc)
{
desc.Field(t => t.FriendIds).Ignore();
desc.Field<PersonResolver>(t => t.GetFriends(default, default));
}
}
With version 0.5 we will focus on subscriptions and custom directives.
Custom will allow for writing field resolver middlewares that alter or replace the default execution behavior.
Subscriptions is one of our last spec gaps.