EntityGraphQL 2.0.0-beta4
See the version list below for details.
dotnet add package EntityGraphQL --version 2.0.0-beta4
NuGet\Install-Package EntityGraphQL -Version 2.0.0-beta4
<PackageReference Include="EntityGraphQL" Version="2.0.0-beta4" />
<PackageVersion Include="EntityGraphQL" Version="2.0.0-beta4" />
<PackageReference Include="EntityGraphQL" />
paket add EntityGraphQL --version 2.0.0-beta4
#r "nuget: EntityGraphQL, 2.0.0-beta4"
#:package EntityGraphQL@2.0.0-beta4
#addin nuget:?package=EntityGraphQL&version=2.0.0-beta4&prerelease
#tool nuget:?package=EntityGraphQL&version=2.0.0-beta4&prerelease
Entity GraphQL
A GraphQL library for .NET Core
Jump into the https://entitygraphql.github.io/ for documentation and to get started.
Entity GraphQL is a .NET Core (netstandard 2.1) library that allows you to easily build a GraphQL API on top of your data with the extensibility to bring multiple data sources together in the single GraphQL schema.
It can also be used to execute simple LINQ-style expressions at runtime against a given object which provides powerful runtime configuration.
Please explore, give feedback or join the development.
If you're looking for a dotnet library to generate code to query an API from a GraphQL schema see https://github.com/lukemurray/DotNetGraphQLQueryGen
Installation
Via Nuget
Quick Start with Entity Framework
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.
1. Define your data context (in this example an EF context)
public class DemoContext : DbContext {
  public DemoContext(DbContextOptions options) : base(options)
  {
  }
  protected override void OnModelCreating(ModelBuilder builder) {
    // Set up your relations
  }
  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; }
}
2. Create a route
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.
public class Startup {
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddDbContext<DemoContext>(opt => opt.UseInMemoryDatabase());
      // This registers a SchemaProvider<DemoContext>
      services.AddGraphQLSchema<DemoContext>();
  }
  public void Configure(IApplicationBuilder app, DemoContext db)
  {
      app.UseRouting();
      app.UseEndpoints(endpoints =>
      {
          // default to /graphql endpoint
          endpoints.MapGraphQL<DemoContext>();
      });
  }
}
This sets up 1 end point:
POSTat/graphqlwhere the body of the post is a GraphQL query- You can authorize that route how you would any ASP.NET route. See Authorization below for details on having parts of the schema requiring Authorization/Claims
 
Note - As of version 1.1+ the EntityGraphQL.AspNet extension helper uses System.Text.Json. Previous versions used JSON.NET.
3. Build awesome applications
You 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.
Using expressions else where (EQL)
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);
Contribute & Join the Development
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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. | 
| .NET Standard | netstandard2.1 is compatible. | 
| MonoAndroid | monoandroid was computed. | 
| MonoMac | monomac was computed. | 
| MonoTouch | monotouch was computed. | 
| Tizen | tizen60 was computed. | 
| Xamarin.iOS | xamarinios was computed. | 
| Xamarin.Mac | xamarinmac was computed. | 
| Xamarin.TVOS | xamarintvos was computed. | 
| Xamarin.WatchOS | xamarinwatchos was computed. | 
- 
                                                    
.NETStandard 2.1
- Antlr4 (>= 4.6.6)
 - Antlr4.Runtime (>= 4.6.6)
 - HotChocolate.Language (>= 11.3.5)
 - Humanizer.Core (>= 2.11.10)
 - Microsoft.CSharp (>= 4.7.0)
 - Microsoft.Extensions.DependencyInjection (>= 5.0.2)
 - Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
 - Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
 - Newtonsoft.Json (>= 13.0.1)
 - System.ComponentModel.Annotations (>= 5.0.0)
 - System.Reflection.Emit (>= 4.7.0)
 - System.Reflection.TypeExtensions (>= 4.7.0)
 - System.Text.Json (>= 6.0.0)
 
 
NuGet packages (3)
Showing the top 3 NuGet packages that depend on EntityGraphQL:
| Package | Downloads | 
|---|---|
| 
                                                        
                                                            EntityGraphQL.AspNet
                                                        
                                                         Contains ASP.NET extensions and middleware for EntityGraphQL  | 
                                                    |
| 
                                                        
                                                            Zen.Web.GraphQL
                                                        
                                                         Package Description  | 
                                                    |
| 
                                                        
                                                            SiteCauldron.GenericAPI
                                                        
                                                         SiteCauldron Generic API utilities for Web MVC applications. Provides a few controllers to cover most use cases, so that you mostly won't have to program a CRUD again.  | 
                                                    
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | 
|---|---|---|
| 6.0.0-beta2 | 297 | 9/30/2025 | 
| 6.0.0-beta1 | 290 | 9/16/2025 | 
| 5.7.1 | 10,228 | 8/12/2025 | 
| 5.7.0 | 2,393 | 8/6/2025 | 
| 5.6.1 | 12,455 | 4/28/2025 | 
| 5.6.0 | 37,623 | 1/29/2025 | 
| 5.5.3 | 25,411 | 11/24/2024 | 
| 5.5.2 | 1,474 | 11/15/2024 | 
| 5.5.1 | 272 | 11/14/2024 | 
| 5.5.0 | 1,632 | 10/25/2024 | 
| 5.4.6 | 13,520 | 9/23/2024 | 
| 5.4.5 | 1,149 | 9/13/2024 | 
| 5.4.4 | 292 | 9/12/2024 | 
| 5.4.3 | 2,479 | 9/3/2024 | 
| 5.4.2 | 361 | 9/2/2024 | 
| 5.4.1 | 13,947 | 7/15/2024 | 
| 5.4.0 | 6,362 | 6/2/2024 | 
| 5.3.0 | 14,698 | 5/7/2024 | 
| 5.2.1 | 5,752 | 4/8/2024 | 
| 5.2.0 | 5,901 | 3/19/2024 | 
| 5.2.0-beta2 | 708 | 2/11/2024 | 
| 5.2.0-beta1 | 4,346 | 11/16/2023 | 
| 5.1.1 | 12,687 | 1/24/2024 | 
| 5.1.0 | 10,800 | 11/16/2023 | 
| 5.0.1 | 7,400 | 9/28/2023 | 
| 5.0.0 | 3,207 | 8/2/2023 | 
| 5.0.0-beta1 | 983 | 6/17/2023 | 
| 4.3.1 | 645 | 11/22/2023 | 
| 4.3.0 | 7,593 | 3/14/2023 | 
| 4.2.1 | 13,945 | 12/22/2022 | 
| 4.2.0 | 5,999 | 11/16/2022 | 
| 4.1.2 | 2,173 | 10/20/2022 | 
| 4.1.1 | 1,531 | 10/18/2022 | 
| 4.1.0 | 1,504 | 10/13/2022 | 
| 4.0.1 | 1,893 | 10/5/2022 | 
| 4.0.0 | 2,542 | 9/10/2022 | 
| 4.0.0-beta2 | 1,354 | 9/8/2022 | 
| 4.0.0-beta1 | 945 | 9/6/2022 | 
| 3.0.5 | 1,832 | 8/16/2022 | 
| 3.0.4 | 1,509 | 8/5/2022 | 
| 3.0.3 | 1,919 | 8/4/2022 | 
| 3.0.2 | 1,641 | 8/1/2022 | 
| 3.0.1 | 1,368 | 8/1/2022 | 
| 3.0.0 | 1,510 | 7/31/2022 | 
| 2.3.2 | 1,652 | 7/18/2022 | 
| 2.3.1 | 1,811 | 7/14/2022 | 
| 2.3.0 | 1,680 | 7/4/2022 | 
| 2.2.0 | 3,525 | 7/1/2022 | 
| 2.1.5 | 3,329 | 6/13/2022 | 
| 2.1.4 | 1,388 | 6/11/2022 | 
| 2.1.3 | 1,939 | 6/6/2022 | 
| 2.1.2 | 1,519 | 5/23/2022 | 
| 2.1.1 | 1,759 | 5/18/2022 | 
| 2.1.0 | 1,390 | 5/17/2022 | 
| 2.0.3 | 1,404 | 5/9/2022 | 
| 2.0.2 | 1,486 | 5/6/2022 | 
| 2.0.1 | 1,402 | 5/5/2022 | 
| 2.0.0 | 1,518 | 4/29/2022 | 
| 2.0.0-beta7 | 867 | 4/27/2022 | 
| 2.0.0-beta6 | 877 | 4/25/2022 | 
| 2.0.0-beta5 | 2,302 | 4/14/2022 | 
| 2.0.0-beta4 | 971 | 4/13/2022 | 
| 2.0.0-beta3 | 909 | 4/13/2022 | 
| 2.0.0-beta2 | 961 | 4/11/2022 | 
| 2.0.0-beta1 | 6,278 | 4/7/2022 | 
| 1.2.0 | 19,424 | 2/15/2022 | 
| 1.1.2 | 1,456 | 2/11/2022 | 
| 1.1.1 | 1,515 | 2/9/2022 | 
| 1.1.0 | 3,049 | 1/13/2022 | 
| 1.1.0-beta2 | 911 | 1/8/2022 | 
| 1.1.0-beta1 | 857 | 1/8/2022 | 
| 1.0.3 | 988 | 12/28/2021 | 
| 1.0.2 | 8,280 | 10/20/2021 | 
| 1.0.1 | 13,788 | 9/30/2021 | 
| 1.0.0 | 1,271 | 9/28/2021 | 
| 1.0.0-beta2 | 970 | 9/15/2021 | 
| 1.0.0-beta1 | 889 | 9/13/2021 | 
| 0.70.0 | 4,023 | 8/30/2021 | 
| 0.69.0 | 1,587 | 8/18/2021 | 
| 0.69.0-beta7 | 927 | 8/12/2021 | 
| 0.69.0-beta6 | 954 | 8/10/2021 | 
| 0.69.0-beta5 | 917 | 8/9/2021 | 
| 0.69.0-beta4 | 967 | 8/6/2021 | 
| 0.69.0-beta3 | 924 | 8/5/2021 | 
| 0.69.0-beta2 | 1,550 | 7/24/2021 | 
| 0.69.0-beta1 | 1,009 | 7/16/2021 | 
| 0.68.1 | 2,480 | 4/5/2021 | 
| 0.66.1 | 15,739 | 10/5/2020 | 
| 0.66.0 | 1,483 | 9/22/2020 | 
| 0.65.0 | 1,327 | 9/17/2020 | 
| 0.64.0 | 1,929 | 9/1/2020 | 
| 0.63.0 | 2,009 | 6/10/2020 | 
| 0.63.0-beta3 | 2,108 | 6/4/2020 | 
| 0.63.0-beta2 | 1,110 | 6/4/2020 | 
| 0.63.0-beta1 | 1,120 | 6/3/2020 | 
| 0.62.0 | 1,431 | 5/27/2020 | 
| 0.61.0 | 1,329 | 5/14/2020 | 
| 0.60.0 | 1,341 | 5/9/2020 | 
| 0.60.0-beta3 | 1,465 | 5/4/2020 | 
| 0.60.0-beta1 | 1,343 | 4/22/2020 | 
| 0.50.0 | 4,209 | 4/1/2020 | 
| 0.50.0-beta1 | 1,174 | 3/24/2020 | 
| 0.40.0 | 1,504 | 3/19/2020 | 
| 0.32.1 | 1,904 | 3/3/2020 | 
| 0.32.0 | 1,925 | 2/14/2020 | 
| 0.31.0 | 1,669 | 2/6/2020 | 
| 0.30.0 | 2,523 | 1/23/2020 | 
| 0.29.0 | 1,348 | 1/21/2020 | 
| 0.28.1 | 1,741 | 1/8/2020 | 
| 0.28.0 | 1,462 | 1/8/2020 | 
| 0.27.2 | 1,337 | 1/8/2020 | 
| 0.27.1 | 1,361 | 1/7/2020 | 
| 0.27.0 | 1,367 | 1/6/2020 | 
| 0.26.0 | 5,191 | 1/2/2020 | 
| 0.25.0 | 2,061 | 11/19/2019 | 
| 0.24.0 | 1,426 | 11/12/2019 | 
| 0.23.3 | 1,429 | 11/4/2019 | 
| 0.23.2 | 1,424 | 11/2/2019 | 
| 0.23.1 | 1,402 | 10/31/2019 | 
| 0.23.0 | 1,381 | 10/30/2019 | 
| 0.22.0 | 1,381 | 10/30/2019 | 
| 0.21.0 | 2,685 | 9/3/2019 | 
| 0.20.1 | 1,422 | 8/28/2019 | 
| 0.20.0 | 1,380 | 8/28/2019 | 
| 0.19.1 | 1,515 | 8/26/2019 | 
| 0.19.0 | 1,399 | 8/25/2019 | 
| 0.18.4 | 1,524 | 8/19/2019 | 
| 0.18.3 | 1,558 | 7/30/2019 | 
| 0.18.2 | 1,654 | 7/26/2019 | 
| 0.18.1 | 1,507 | 7/18/2019 | 
| 0.18.0 | 1,535 | 7/17/2019 | 
| 0.17.0 | 1,676 | 7/8/2019 | 
| 0.16.2 | 1,957 | 6/1/2019 | 
| 0.16.1 | 1,551 | 5/27/2019 | 
| 0.16.0 | 1,607 | 5/21/2019 | 
| 0.15.8 | 1,686 | 4/11/2019 | 
| 0.15.7 | 1,519 | 4/11/2019 | 
| 0.15.6 | 10,682 | 3/15/2019 | 
| 0.15.5 | 1,507 | 3/14/2019 | 
| 0.15.4 | 1,542 | 3/8/2019 | 
| 0.15.3 | 1,537 | 3/6/2019 | 
| 0.15.2 | 1,530 | 2/22/2019 | 
| 0.15.1 | 1,811 | 2/14/2019 | 
| 0.15.0 | 1,662 | 2/5/2019 | 
| 0.14.4 | 1,704 | 1/29/2019 | 
| 0.14.3 | 1,611 | 1/25/2019 | 
| 0.14.2 | 1,597 | 1/22/2019 | 
| 0.14.1 | 1,607 | 1/21/2019 | 
| 0.14.0 | 1,675 | 1/14/2019 | 
| 0.13.1 | 1,631 | 1/9/2019 | 
| 0.13.0 | 1,631 | 1/3/2019 | 
| 0.12.1 | 1,722 | 12/18/2018 | 
| 0.12.0 | 1,595 | 12/13/2018 | 
| 0.11.0 | 1,727 | 11/13/2018 |