/QP.GraphQL

Primary LanguageC#Mozilla Public License 2.0MPL-2.0

QP GraphQL Server

Table of contents

1. Introduction

QP GraphQL Server is a web application on dotnet core 5.0. It serves to perform GraphQL queries over QP database. GraphQL Specification is also available.

2. Dependencies

The application depens on NuGet packages:

2.1 GraphQL

2.2 Microsoft.Data.SqlClient

2.3 Npgsql

2.4 Dapper

2.5 NLog.Web.AspNetCore

3. Configuration

Configuration is available on appsettings.json file.

Postgres settings

  "ConnectionStrings": {
    "QPConnectionString": "Server=dbserver;Database=dbname;User Id=user;Password=password",
    "Type": "Postgres"
  },

SqlServer settings

  "ConnectionStrings": {
    "QPConnectionString": "Initial Catalog=dbname;Data Source=dbserver;User ID=user;Password=password",
    "Type": "SqlServer"
  },

4. Structured logging

5. Trace SQL

6. Reload Schema

Configuration is available on appsettings.json file.

  "SchemaAutoReload": true,
  "SchemaReloadInterval": "00:02:00",

Reload API

  • POST /api/schema/reload reload schema
  • GET /api/schema/context get current schema context

One can reload the schema directly in the browser console:

await (await fetch('/api/schema/reload', { method: 'POST' })).json();

4. Deployment

4.1 Docker

One can build and run docker containers manually. It's the easiest way to run the application. Here basic commands for docker.

Build image

docker build -t qp.graphql -f QP.GraphQL.App/Dockerfile .

Run the application in docker container on port 8889

docker run -it -p 8889:80 -e ConnectionStrings__QPConnectionString="{db connection}" -e ConnectionStrings__Type="{db type}" --rm --name=qp.graphql qp.graphql

where

  • {db connection} is the database connection
  • {db type} is the database type whether SqlServer or Postgres

Stop container if running

docker stop qp.graphql

Application is available on Localhost

4.2 Docker registry

4.2.1 Checking the registry

Image tags.

4.2.1 Running the application

docker run -it -p 8890:80 -e ConnectionStrings__QPConnectionString="{db connection}" -e ConnectionStrings__Type="{db type}" --rm --name=qp-graphql-service qpcms/qp-graphql-service:{tag}

where

  • {tag} is application version
  • {db connection} is the database connection
  • {db type} is the database type whether SqlServer or Postgres

Application is available on Localhost