Skip to main content

Entity GraphQL

A modern .NET Core GraphQL library

1. Define your schema

EntityGraphQL was designed to get you up and running quickly. Expose your existing object graph (EF DbContext is supported) or build your own schema.

EntityGraphQL uses reflection to generate your schema from your existing object graph - you can use attributes and options to control what is generated. Or you can create one from scratch only adding the types and fields you require.

Learn more about schema creation

public class DemoContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
public DbSet<Actor> Actors { get; set; }
}

public class Movie
{
public int Id { get; set; }
public string Name { get; set; }
public Genre Genre { get; set; }
}
// all the rest...

2. Register and customize your schema

EntityGraphQL integrates easily into ASP.NET allowing you to provide the customization you need.

You can also use EntityGraphQL directly without ASP.NET (no dependency on EF either) or in a more custom way in your own controller. You can also define multiple schemas that provide different access or functionality.

Learn more

Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddGraphQLSchema<DemoContext>();
}

public void Configure(IApplicationBuilder app, DemoContext db)
{
app.UseEndpoints(endpoints =>
{
endpoints.MapGraphQL<DemoContext>();
});
}

3. Query your API

You're now set to query your API. Add mutations, connect other data sources and secure your data.

EntityGraphQL provides a rich set of features for you to build out your APIs as you add features.

Get started

query MyQuery {
movie(id: 19) {
name
genre
actors {
id
name
}
}
}