Skip to content

TechyChap/GraphQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Star Wars GraphQL Query Example

I put this together from a selection of references I found on the web. None of which seemed to give the whole picture or were overly complex.

A .Net Core 3.0 application using the ASP Middleware to respond to HTTP requests. Configured for graphql queries. Listening on the end point /graphql, ports configured in the appsettings.json

Uses the Graphql Dot Net package and server package

Setup

I used the following to create the basic framework and then edited based on the examples linked below.

dotnet new sln
dotnet new web --name App
cd App
dotnet add package GraphQL
dotnet add package GraphQL.Server.Transports.AspNetCore

Example Queries

  • graphql?Query={ jedis { name, side } }

Expected Response

{
    "data": {
        "jedis": [
          {
              "name": "Luke",
              "side": "Light"
          },
          {
              "name": "Yoda",
              "side": "Light"
          },
          {
              "name": "Darth Vader",
              "side": "Dark"
          }
        ]
    }
 }
  • graphql?Query={ jedi(id: 1) { name } }

Expected Response

{
    "data": {
        "jedi": {
            "name": "Luke"
                }
            }
}

Reference:

About

A demo of graphql using ASP .Net Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages