{"id":13415282,"url":"https://github.com/EntityGraphQL/EntityGraphQL","last_synced_at":"2025-03-14T22:33:13.811Z","repository":{"id":34568723,"uuid":"38514759","full_name":"EntityGraphQL/EntityGraphQL","owner":"EntityGraphQL","description":"A GraphQL library for .NET","archived":false,"fork":false,"pushed_at":"2025-02-20T02:45:13.000Z","size":8847,"stargazers_count":435,"open_issues_count":19,"forks_count":58,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-08T17:33:08.289Z","etag":null,"topics":["csharp","dotnet","graphql","graphql-server"],"latest_commit_sha":null,"homepage":"https://entitygraphql.github.io/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EntityGraphQL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-03T23:49:45.000Z","updated_at":"2025-03-02T08:04:31.000Z","dependencies_parsed_at":"2023-12-26T04:22:22.088Z","dependency_job_id":"b33a2ebc-8eac-4e68-8e47-f23276f46fd5","html_url":"https://github.com/EntityGraphQL/EntityGraphQL","commit_stats":{"total_commits":1172,"total_committers":35,"mean_commits":33.48571428571429,"dds":"0.49146757679180886","last_synced_commit":"4b05580d952abd7325597cb4bb5df5de50533169"},"previous_names":["lukemurray/entitygraphql","lukemurray/entityquerylanguage"],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EntityGraphQL%2FEntityGraphQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EntityGraphQL%2FEntityGraphQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EntityGraphQL%2FEntityGraphQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EntityGraphQL%2FEntityGraphQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EntityGraphQL","download_url":"https://codeload.github.com/EntityGraphQL/EntityGraphQL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658057,"owners_count":20326459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","graphql","graphql-server"],"created_at":"2024-07-30T21:00:46.509Z","updated_at":"2025-03-14T22:33:13.803Z","avatar_url":"https://github.com/EntityGraphQL.png","language":"C#","readme":"# Entity GraphQL\n\n## A GraphQL library for .NET Core\n\n![Build](https://github.com/lukemurray/EntityGraphQL/actions/workflows/dotnet.yml/badge.svg)\n\nHead to [entitygraphql.github.io](https://entitygraphql.github.io/) for documentation and to get started.\n\nEntityGraphQL is a .NET library that allows you to easily build a [GraphQL API](https://graphql.org/learn/) on top of your data model with the extensibility to easily bring multiple data sources together in the single GraphQL schema.\n\nEntityGraphQL 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.\n\nA 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](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/) projection operator [`Select()`](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/projection-operations#select) hence it works across any object tree.\n\n_Please explore, give feedback or join the development._\n\n## Installation\n\nThe [EntityGraphQL.AspNet ![Nuget](https://img.shields.io/nuget/dt/EntityGraphQL.AspNet)](https://www.nuget.org/packages/EntityGraphQL.AspNet) package will get you easily set up with ASP.NET.\n\nHowever the core [EntityGraphQL ![Nuget](https://img.shields.io/nuget/dt/EntityGraphQL)](https://www.nuget.org/packages/EntityGraphQL) package has no ASP.NET dependency.\n\n# Quick Start with Entity Framework\n\n_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._\n\n## 1. Define your data context (in this example an EF context)\n\n```c#\npublic class DemoContext : DbContext {\n  public DbSet\u003cProperty\u003e Properties { get; set; }\n  public DbSet\u003cPropertyType\u003e PropertyTypes { get; set; }\n  public DbSet\u003cLocation\u003e Locations { get; set; }\n}\n\npublic class Property {\n  public uint Id { get; set; }\n  public string Name { get; set; }\n  public PropertyType Type { get; set; }\n  public Location Location { get; set; }\n}\n\npublic class PropertyType {\n  public uint Id { get; set; }\n  public string Name { get; set; }\n  public decimal Premium { get; set; }\n}\n\npublic class Location {\n  public uint Id { get; set; }\n  public string Name { get; set; }\n}\n```\n\n## 2. Create a route\n\nHere 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.\n\n[![Nuget](https://img.shields.io/nuget/dt/EntityGraphQL.AspNet)](https://www.nuget.org/packages/EntityGraphQL.AspNet)\n\n```c#\nusing EntityGraphQL.AspNet;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddDbContext\u003cDemoContext\u003e(opt =\u003e opt.UseInMemoryDatabase(\"Demo\"));\nbuilder.Services.AddGraphQLSchema\u003cDemoContext\u003e();\n\nvar app = builder.Build();\n\napp.MapGraphQL\u003cDemoContext\u003e();\n\napp.Run();\n```\n\nThis sets up 1 end point:\n\n- `POST` at `/graphql` where the body of the post is a GraphQL query\n- 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\n\n_Note - As of version 1.1+ the EntityGraphQL.AspNet extension helper uses System.Text.Json. Previous versions used JSON.NET._\n\n## 3. Build awesome applications\n\nYou can now make a request to your API. For example\n\n```\n  POST localhost:5000/graphql\n  {\n    properties { id name }\n  }\n```\n\nWill return the following result.\n\n```json\n{\n  \"data\": {\n    \"properties\": [\n      {\n        \"id\": 11,\n        \"name\": \"My Beach Pad\"\n      },\n      {\n        \"id\": 12,\n        \"name\": \"My Other Beach Pad\"\n      }\n    ]\n  }\n}\n```\n\nMaybe you only want a specific property\n\n```\n  {\n    property(id: 11) {\n      id name\n    }\n  }\n```\n\nWill return the following result.\n\n```json\n{\n  \"data\": {\n    \"property\": {\n      \"id\": 11,\n      \"name\": \"My Beach Pad\"\n    }\n  }\n}\n```\n\nIf you need a deeper graph or relations, just ask\n\n```\n  {\n    properties {\n      id\n      name\n      location {\n        name\n      }\n      type {\n        premium\n      }\n    }\n  }\n```\n\nWill return the following result.\n\n```json\n{\n  \"data\": {\n    \"properties\": [\n      {\n        \"id\": 11,\n        \"name\": \"My Beach Pad\",\n        \"location\": {\n          \"name\": \"Greece\"\n        },\n        \"type\": {\n          \"premium\": 1.2\n        }\n      },\n      {\n        \"id\": 12,\n        \"name\": \"My Other Beach Pad\",\n        \"location\": {\n          \"name\": \"Spain\"\n        },\n        \"type\": {\n          \"premium\": 1.25\n        }\n      }\n    ]\n  }\n}\n```\n\nVisit [documentation](https://entitygraphql.github.io/) for more information.\n\n# Using expressions else where (EQL)\n\nLets 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.\n\n```cs\n  // This might be a configured EQL statement for filtering the results. It has a context of Property\n  (type.id = 2) or (type.id = 3) and type.name = \"Farm\"\n```\n\nThis would compile to `(Property p) =\u003e (p.Type.Id == 2 || p.Type.Id == 3) \u0026\u0026 p.Type.Name == \"Farm\";`\n\nThis can then be used in various Linq functions either in memory or against an ORM.\n\n```csharp\n// we create a schema provider to compile the statement against our Property type\nvar schemaProvider = SchemaBuilder.FromObject\u003cProperty\u003e();\nvar compiledResult = EntityQueryCompiler.Compile(myConfigurationEqlStatement, schemaProvider);\n// you get your list of Properties from you DB\nvar thingsToShow = myProperties.Where(compiledResult.LambdaExpression);\n```\n\nAnother example is you want a customised calculated field. You can execute a compiled result passing in an instance of the context type.\n\n```csharp\n// You'd take this from some configuration\nvar eql = @\"if location.name = \"\"Mars\"\" then (cost + 5) * type.premium else (cost * type.premium) / 3\"\nvar compiledResult = EntityQueryCompiler.Compile(eql, schemaProvider);\nvar theRealPrice = compiledResult.Execute\u003cdecimal\u003e(myPropertyInstance);\n```\n\n# Versioning\n\nWe do our best to follow [Semantic Versioning](https://semver.org):\n\nGiven a version number `MAJOR.MINOR.PATCH`, an increment in:\n\n- `MAJOR` version is when we make incompatible API changes,\n- `MINOR` version is when we add functionality in a backwards compatible manner, and\n- `PATCH` version is when we make backwards compatible bug fixes.\n\n# Contribute \u0026 Join the Development\n\nPlease do. Pull requests are very welcome. See the open issues for bugs or features that would be useful.\n","funding_links":[],"categories":["GraphQL","Implementations"],"sub_categories":[".NET"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEntityGraphQL%2FEntityGraphQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEntityGraphQL%2FEntityGraphQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEntityGraphQL%2FEntityGraphQL/lists"}