Skip to content

The repository contains a backend of a simple Conference Planner and serves as a GraphQL server.

License

Notifications You must be signed in to change notification settings

gayankanishka/graphql-clean-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Clean Architecture with Hot Chocolate

Build and Push to Docker Hub

chilli cream log

The repository contains a backend of a simple Conference Planner. The backend serves as a GraphQL server. You could either use InMemoryDatabase or PostgreSQL to persist the data. Application has docker container orchestration configured.

DISCLAIMER: Original non-layered solution could be found at ChilliCream/graphql-workshop. This repository focuses on applying the clean-architecture principles into the above solution. Also this repository contains some additional features.

Database Schema

database schema

What's included:

Table of Content

Quick Start

After setting up your local DEV environment, you can clone this repository and run the solution.

Prerequisites

You'll need the following tools:

Development Environment Setup

First clone this repository locally.

  • Install all of the the prerequisite tools mentioned above.

Docker Configuration

In order to get Docker working, you will need to add a temporary SSL cert and mount a volume to hold that cert. You can find Microsoft Docs that describe the steps required for Windows, macOS, and Linux.

The following will need to be executed from your terminal to create a cert.

For Windows:

dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p 1qaz2wsx@
dotnet dev-certs https --trust

FOR macOS:

dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p 1qaz2wsx@
dotnet dev-certs https --trust

FOR Linux:

dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p 1qaz2wsx@

In order to build and run the docker containers locally, execute below command from the root of the solution.

docker-compose -f 'docker-compose.yml' up --build

Database Configuration

The default configuration of the application is to use an InMemory database for persistence.

If you would like to use PostgreSQL as the db layer, you will need to update src/GraphQL/appsettings.json as follows:

{
  "ConnectionStrings": {
    "PostgresDbConnection": "YOUR_POSTGRES_CONNECTION_STRING"
  },
  "UseInMemoryDatabase": "false"
}

When you run the application the database will be automatically created (if necessary) and the latest migrations will be applied. The sample test data in NDC_London_2019.json will be imported automatically.

Database Migrations

To use dotnet-ef for your migrations run below commands from the root of the project.

Run Migrations:

dotnet ef migrations add InitialMigration --project src/Infrastructure --startup-project src/GraphQL --output-dir Persistence/Migrations

Update database:

dotnet ef database update --project src/Infrastructure --startup-project src/GraphQL

Build and run from source

With Visual studio: Open up the solutions using Visual studio.

  • Restore solution nuget packages.
  • Rebuild solution once.
  • Run the solution.
  • Banana cake pop local URL here.
  • Voyager local URL here

License

Licensed under the MIT license.

PRs Welcomed