Semi automatic Relay compatible GraphQL for C#
Nitrolize accelerates your GraphQL server development in C#.
Based on GraphQL for .NET it offers
Your user domain model:
public class User
{
public Guid Id { get;set; }
public string NickName { get; set; }
public string Mail { get; set; }
public int FavoriteNumber { get; set; }
}
Your ViewerType:
public class ViewerType : NitrolizeViewerType
{
private readonly IUserRepository userRepository;
public ViewerType(IUserRepository userRepository)
{
this.userRepository = userRepository;
}
/// <summary>
/// Gets a user by id.
/// </summary>
[Field]
public Field<User, Guid> User => (context, id) =>
{
return this.userRepository.GetUserById(id);
};
/// <summary>
/// Gets all users.
/// </summary>
[Connection]
public ConnectionField<User> Users => (context, parameters) =>
{
return new Connection<User, Guid>(this.userRepository.GetAllUsers());
};
}
Possible GraphQL query:
{
viewer {
users {
edges {
cursor
node {
id
nickName
favoriteNumber
}
}
}
user(id: "VXNlciNjYWVmYjc5Mi04ODFmLTRmMjAtYmI5ZC1jNDAzMjY5OGQxMGM=") {
nickName
favoriteNumber
}
}
}