Giter Site home page Giter Site logo

graphql-core's Introduction

GraphQL-Core

This demo is based on https://github.com/mmacneil/ASPNetCoreGraphQL with an accompanying blog on https://fullstackmark.com/post/17/building-a-graphql-api-with-aspnet-core-2-and-entity-framework-core

GraphQL API

  • .NET Core 2.2
  • SQL Server 2017 (may support lower versions, this codebase was created against 2017 and Azure SQL)
  • Hangfire
  • Azure SignalR
  • NLog
  • React
  • Apollo

Still in development

For the Database, create two databases: NHLStats and HangfireGQL

Create a appsettings.Development.json for both GraphQL.API and GraphQL.Console applications and add the following:

  "ConnectionStrings": {
    "DefaultConnection": "Server=SERVER;Initial Catalog=NHLStats;Persist Security Info=False;User ID=USERID;Password=PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
    "HangfireConnection": "Server=SERVER;Initial Catalog=HangfireGQL;Persist Security Info=False;User ID=USERID;Password=PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
  },
  "Azure": {
    "SignalR": {
        "ConnectionString": "Endpoint=AZURE-SIGNALR-ENDPOINT;"
    }
  },  

Install React components and restore .NET core project

yarn --cwd "services/GraphQL.Api/clientApp" install
dotnet restore

To launch, run dotnet run --project services/GraphQL.Api or dotnet watch --project services/GraphQL.Api run

This will start both server and react application(via webpack) using Spa Services. React application was created with CRA.

Hangfire Dashboard: http://localhost:50000/hangfire/

GraphQL Playground: http://localhost:50000/ui/playground/

GraphQL Schema found under services/GraphQL.Api/schema/schema.graphql

To generate schema file:

npm install -g graphql-cli
cd services/GraphQL.Api/schema
graphql get-schema

Mutation example

Create
mutation ($player: PlayerInput!, $skaterStats: [SkaterStatisticInput]) {
    createPlayer(player: $player, skaterStats: $skaterStats) {
        id name skaterSeasonStats {
          id
        }
    }
}

vars

{
    "player": {
        "name": "Jaromir Jagr",
        "birthPlace": "Kladno, Czech Republic",
        "height": "6'03",
        "weightLbs": 230,
        "birthDate": "1972-02-15"
    },
    "skaterStats": [
            {
            "seasonId": 17,
            "leagueId": 1,
            "teamId": 5,
            "gamesPlayed": 82,
            "goals": 24,
            "assists": 43,
            "points": 67,
            "plusMinus": 16

    }]
        
}
Delete
mutation ($playerId: Int!) {
    deletePlayer(playerId: $playerId) {
        id, statusType
    }
}

vars

{
    "playerId": 5   
}

GraphQL.ConsoleApp and GraphQL.Api

Hangfire Console

  • .NET Core 2.1
  • Hangfire
  • Azure SignalR
  • NLog

Still in development

Create a appsettings.Development.json for both GraphQL.API and GraphQL.Console applications and add the following:

  "ConnectionStrings": {
    "DefaultConnection": "Server=SERVER;Initial Catalog=NHLStats;Persist Security Info=False;User ID=USERID;Password=PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
    "HangfireConnection": "Server=SERVER;Initial Catalog=HangfireGQL;Persist Security Info=False;User ID=USERID;Password=PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
  },
    "Azure": {
    "SignalR": {
      "ConnectionString": "Endpoint=AZURE-REDIS-ENDPOINT;"
    }
  },

dotnet run --project services/GraphQL.ConsoleApp

graphql-core's People

Contributors

aurlaw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.