![]() |
VOOZH | about |
dotnet add package EntityGraphQL.AspNet --version 5.7.2
NuGet\Install-Package EntityGraphQL.AspNet -Version 5.7.2
<PackageReference Include="EntityGraphQL.AspNet" Version="5.7.2" />
<PackageVersion Include="EntityGraphQL.AspNet" Version="5.7.2" />Directory.Packages.props
<PackageReference Include="EntityGraphQL.AspNet" />Project file
paket add EntityGraphQL.AspNet --version 5.7.2
#r "nuget: EntityGraphQL.AspNet, 5.7.2"
#:package EntityGraphQL.AspNet@5.7.2
#addin nuget:?package=EntityGraphQL.AspNet&version=5.7.2Install as a Cake Addin
#tool nuget:?package=EntityGraphQL.AspNet&version=5.7.2Install as a Cake Tool
Head to entitygraphql.github.io for documentation and to get started.
EntityGraphQL is a .NET library that allows you to easily build a GraphQL API on top of your data model with the extensibility to easily bring multiple data sources together in the single GraphQL schema.
EntityGraphQL builds a GraphQL schema that maps to .NET objects. It provides the functionality to parse a GraphQL query document and execute that against your mapped objects. These objects can be an Entity Framework DbContext or any other .NET object, it doesn't matter.
A core feature of EntityGraphQL with Entity Framework (although EF is not a requirement) is that it builds selections of only the fields requested in the GraphQL query which means Entity Framework is not returning all columns from a table. This is done with the LINQ projection operator Select() hence it works across any object tree.
Please explore, give feedback or join the development.
The EntityGraphQL.AspNet 👁 Nuget
package will get you easily set up with ASP.NET.
However the core EntityGraphQL 👁 Nuget
package has no ASP.NET dependency.
Note: There is no dependency on EF. Queries are compiled to IQueryable or IEnumberable linq expressions. EF is not a requirement - any ORM working with LinqProvider or an in-memory object will work - although EF well is tested.
public class DemoContext : DbContext {
public DbSet<Property> Properties { get; set; }
public DbSet<PropertyType> PropertyTypes { get; set; }
public DbSet<Location> Locations { get; set; }
}
public class Property {
public uint Id { get; set; }
public string Name { get; set; }
public PropertyType Type { get; set; }
public Location Location { get; set; }
}
public class PropertyType {
public uint Id { get; set; }
public string Name { get; set; }
public decimal Premium { get; set; }
}
public class Location {
public uint Id { get; set; }
public string Name { get; set; }
}
Here is an example for a ASP.NET. You will also need to install EntityGraphQL.AspNet to use MapGraphQL. You can also build you own endpoint, see docs.
using EntityGraphQL.AspNet;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<DemoContext>(opt => opt.UseInMemoryDatabase("Demo"));
builder.Services.AddGraphQLSchema<DemoContext>();
var app = builder.Build();
app.MapGraphQL<DemoContext>();
app.Run();
This sets up 1 end point:
POST at /graphql where the body of the post is a GraphQL queryYou can now make a request to your API. For example
POST localhost:5000/graphql
{
properties { id name }
}
Will return the following result.
{
"data": {
"properties": [
{
"id": 11,
"name": "My Beach Pad"
},
{
"id": 12,
"name": "My Other Beach Pad"
}
]
}
}
Maybe you only want a specific property
{
property(id: 11) {
id name
}
}
Will return the following result.
{
"data": {
"property": {
"id": 11,
"name": "My Beach Pad"
}
}
}
If you need a deeper graph or relations, just ask
{
properties {
id
name
location {
name
}
type {
premium
}
}
}
Will return the following result.
{
"data": {
"properties": [
{
"id": 11,
"name": "My Beach Pad",
"location": {
"name": "Greece"
},
"type": {
"premium": 1.2
}
},
{
"id": 12,
"name": "My Other Beach Pad",
"location": {
"name": "Spain"
},
"type": {
"premium": 1.25
}
}
]
}
}
Visit documentation for more information.
Lets say you have a screen in your application listing properties that can be configured per customer or user to only show exactly what they are interested in. Instead of having a bunch of checkboxes and complex radio buttons etc. you can allow a simple EQL statement to configure the results shown. Or use those UI components to build the query.
// This might be a configured EQL statement for filtering the results. It has a context of Property
(type.id = 2) or (type.id = 3) and type.name = "Farm"
This would compile to (Property p) => (p.Type.Id == 2 || p.Type.Id == 3) && p.Type.Name == "Farm";
This can then be used in various Linq functions either in memory or against an ORM.
// we create a schema provider to compile the statement against our Property type
var schemaProvider = SchemaBuilder.FromObject<Property>();
var compiledResult = EntityQueryCompiler.Compile(myConfigurationEqlStatement, schemaProvider);
// you get your list of Properties from you DB
var thingsToShow = myProperties.Where(compiledResult.LambdaExpression);
Another example is you want a customised calculated field. You can execute a compiled result passing in an instance of the context type.
// You'd take this from some configuration
var eql = @"if location.name = ""Mars"" then (cost + 5) * type.premium else (cost * type.premium) / 3"
var compiledResult = EntityQueryCompiler.Compile(eql, schemaProvider);
var theRealPrice = compiledResult.Execute<decimal>(myPropertyInstance);
We do our best to follow Semantic Versioning:
Given a version number MAJOR.MINOR.PATCH, an increment in:
MAJOR version is when we make incompatible API changes,MINOR version is when we add functionality in a backwards compatible manner, andPATCH version is when we make backwards compatible bug fixes.Please do. Pull requests are very welcome. See the open issues for bugs or features that would be useful.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on EntityGraphQL.AspNet:
| Package | Downloads |
|---|---|
|
Dino.GraphqlLib
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.0-beta7 | 104 | 6/15/2026 |
| 6.0.0-beta6 | 93 | 6/12/2026 |
| 6.0.0-beta5 | 86 | 6/12/2026 |
| 6.0.0-beta4 | 151 | 4/22/2026 |
| 6.0.0-beta3 | 97 | 4/20/2026 |
| 6.0.0-beta2 | 323 | 9/30/2025 |
| 6.0.0-beta1 | 342 | 9/16/2025 |
| 5.7.2 | 7,537 | 4/20/2026 |
| 5.7.1 | 31,825 | 8/12/2025 |
| 5.7.0 | 3,028 | 8/6/2025 |
| 5.6.1 | 10,764 | 4/28/2025 |
| 5.6.0 | 41,649 | 1/29/2025 |
| 5.5.3 | 21,296 | 11/24/2024 |
| 5.5.2 | 1,824 | 11/15/2024 |
| 5.5.1 | 336 | 11/14/2024 |
| 5.5.0 | 1,759 | 10/25/2024 |
| 5.4.6 | 17,366 | 9/23/2024 |
| 5.4.5 | 1,259 | 9/13/2024 |
| 5.4.4 | 362 | 9/12/2024 |
| 5.4.3 | 2,631 | 9/3/2024 |