GraphR 0.1.7

There is a newer version of this package available.
See the version list below for details.
dotnet new install GraphR::0.1.7
This package contains a .NET Template Package you can call from the shell/command line.

Clean Architecture GraphAPI solution template

Description

Simple Graph API solution template using Dapper ORM for .NET 8 with clean code, clean architecture and CQRS in mind.. Ideal if you need to set up an Graph API on a existing database. Just install and use the template and start adding queries and mutations.

Technologies

Give it a star! ⭐

If you have used this template, learned something or like what you see, consider giving it a star!

Usage

Install GraphR

dotnet new --install GraphR

Scaffold your solution

Create a folder, for example 'MyNewSolution' and run this command inside the folder:

dotnet new graphr -n MyNewSolution

The complete solution will be scaffolded inside your folder. Open it in Visual Studio:

image

Setup

Replace the connectionString in appsettings.json with your own and remove the Seed folder in the Infrastructure project. Remove the example queries/mutation/repositories etc and implement your own.

Architecture overview

WebApi

A .NET 8 WebAPI application, here we have our GraphAPI endpoint. This application depends on the Application layer, and it also has a reference to the Infrastructure layer to wire up the IoC container (dependency injection), so we only use it in the ServiceCollectionExtensions.

Application

This layer contains all application logic and it depends only on the Domain and Core layer. Here we implement the handlers, graphApi input and output types, queries and mutations. This project depends on the Domain and the Core project.

Domain

This will contain all models, enums, exceptions, interfaces, types and logic specific to the domain layer. This project references no other project.

Infrastructure

In this layer we implement the data access (repositories, Dapper implementation, EntityMaps..) and possibly classes to access other external resources. These classes should be based on interfaces defined within the application layer.

Core

This project holds some core logic that we need in our solution. In the template, we have logic that wires up the custom handler system.

Autowiring

This project uses the Bindicate library to autowire dependencies by using attributes, so we don't bloat the ServiceCollectionExtensions.

Test the API

Build and run the project, and navigate to <localhost>/graphql, this will take you to the Banana Cake Pop playground where you can find the graphql schema:

image

You can play around in the Banana Cake Pop playground and test out a query.

For example:

image

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.2 184 4/8/2024
0.2.0 2,092 1/3/2024
0.1.9 818 12/7/2023
0.1.8 180 12/4/2023
0.1.7 182 12/1/2023
0.1.6 142 11/30/2023
0.1.0 262 11/24/2023