GithubHelp home page GithubHelp logo

GraphQL ASP.NET

Targets: netstandard2.0, net6.0, net7.0, net8.0

CI-CD

GraphQL ASP.NET is a fully featured graphql library that utilizes a controller/action programming model familiar to ASP.NET developers. Instead of focusing on schemas and resolvers, the focus on controllers and model objects. This library will automatically generate the schema to match your code.

✅ Controller-Based Programming Model similar to ASP.NET
✅ No Boilerplate Code

✏️ Write This Controller

// BakeryController.cs
[GraphRoute("groceryStore/bakery")]
public class BakeryController : GraphController
{
    [Query("pastries/search")]
    public IEnumerable<IPastry> SearchPastries(string nameLike)
    {/* ... */}

    [Query("pastries/recipe")]
    public Recipe RetrieveRecipe(int id)
    {/* ... */}

    [Query("breadCounter/orders")]
    public IEnumerable<BreadOrder> FindOrders(int customerId)
    {/* ... */}
}

▶️ Execute This Query

query {
  groceryStore {
    bakery {
      pastries {
        search(nameLike: "donut") {
          name
          type
        }
        recipe(id: 15) {
          name
          ingredients {
            name
          }
        }
      }
      breadCounter {
        orders(id: 36) {
          id
          items {
            id
            quantity
          }
        }
      }
    }
  }
}

📦 Add the Package from Nuget:

# Package Manager Console
> Install-Package GraphQL.AspNet

# cli
> dotnet add package GraphQL.AspNet

📐 Register GraphQL with your Application:

// Program.cs 
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGraphQL();
var app = builder.Build();

// Configure the HTTP request pipeline.
app.UseGraphQL();
app.Run();

Subscriptions

GraphQL ASP.NET supports web-socket based subscriptions out of the box. Subscription support can be extended to multi-server environments and even other messaging protocols.

GraphQL ASP.NET's Projects

demo-projects icon demo-projects

A collection of demo projects for different features of the GraphQL ASP.NET library

graphql-aspnet icon graphql-aspnet

A GraphQL library for ASP.NET developers. This repo represents the library's core source code.

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.