https://github.com/michaelhilus/nitrolize
Semi automatic Relay compatible GraphQL for C#
https://github.com/michaelhilus/nitrolize
csharp dotnet-core graphql graphql-server graphql-server-framework semi-automatic
Last synced: 2 months ago
JSON representation
Semi automatic Relay compatible GraphQL for C#
- Host: GitHub
- URL: https://github.com/michaelhilus/nitrolize
- Owner: MichaelHilus
- License: agpl-3.0
- Created: 2017-03-25T22:41:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-13T09:25:36.000Z (almost 8 years ago)
- Last Synced: 2025-04-15T21:16:53.033Z (2 months ago)
- Topics: csharp, dotnet-core, graphql, graphql-server, graphql-server-framework, semi-automatic
- Language: C#
- Size: 120 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

Nitrolize accelerates your GraphQL server development in C#.Based on [GraphQL for .NET](http://github.com/graphql-dotnet/graphql-dotnet) it offers
* mechanisms to auto generate Relay compatible GraphQL Types from your domain model classes,
* auto converts Guid / int Ids from your domain model to Base64 encoded unique ids for your client and vice versa,
* simplifies field declaration by an easy to use syntax.## Example usage
Your user domain model:
```csharp
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:
```csharp
public class ViewerType : NitrolizeViewerType
{
private readonly IUserRepository userRepository;
public ViewerType(IUserRepository userRepository)
{
this.userRepository = userRepository;
}
///
/// Gets a user by id.
///
[Field]
public Field User => (context, id) =>
{
return this.userRepository.GetUserById(id);
};
///
/// Gets all users.
///
[Connection]
public ConnectionField Users => (context, parameters) =>
{
return new Connection(this.userRepository.GetAllUsers());
};
}
```Possible GraphQL query:
```
{
viewer {
users {
edges {
cursor
node {
id
nickName
favoriteNumber
}
}
}
user(id: "VXNlciNjYWVmYjc5Mi04ODFmLTRmMjAtYmI5ZC1jNDAzMjY5OGQxMGM=") {
nickName
favoriteNumber
}
}
}
```