Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

graphql-aspnet/graphql-aspnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL ASP.NET (beta)

Targets: netstandard2.0, net6.0, net7.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 -IncludePrerelease

# cli
> dotnet add package GraphQL.AspNet --prerelease

*This library is still in beta

📐 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.

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.