{"id":23410803,"url":"https://github.com/pmikstacki/hotchocolatier","last_synced_at":"2025-04-12T03:22:59.732Z","repository":{"id":206464292,"uuid":"716958766","full_name":"pmikstacki/HotChocolatier","owner":"pmikstacki","description":"HotChocolate GraphQL Schema Generator for Entity Framework DbSets","archived":false,"fork":false,"pushed_at":"2023-11-10T12:41:05.000Z","size":29,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-01T19:29:32.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pmikstacki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2023-11-10T08:34:22.000Z","updated_at":"2024-04-25T08:47:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a67e46c-6eea-4ac3-a398-9231cdbf9e08","html_url":"https://github.com/pmikstacki/HotChocolatier","commit_stats":null,"previous_names":["pmikstacki/hotchocolatier"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmikstacki%2FHotChocolatier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmikstacki%2FHotChocolatier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmikstacki%2FHotChocolatier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmikstacki%2FHotChocolatier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmikstacki","download_url":"https://codeload.github.com/pmikstacki/HotChocolatier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510736,"owners_count":21116260,"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":[],"created_at":"2024-12-22T17:52:02.587Z","updated_at":"2025-04-12T03:22:59.715Z","avatar_url":"https://github.com/pmikstacki.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HotChocolatier\n![](https://img.shields.io/badge/C%23-239120?style=for-the-badge\u0026logo=c-sharp\u0026logoColor=white) ![](https://img.shields.io/badge/.NET-5C2D91?style=for-the-badge\u0026logo=.net\u0026logoColor=white) [![](https://img.shields.io/nuget/v/HotChocolatier.Adnotations?label=Adnotations%20Package\u0026style=for-the-badge)](https://www.nuget.org/packages/HotChocolatier.Adnotations/) [![](https://img.shields.io/nuget/v/HotChocolatier.Tool?label=Tool\u0026style=for-the-badge)](https://www.nuget.org/packages/HotChocolatier.Tool/)\n\nHotChocolate GraphQL Schema Generator for Entity Framework DbSets\nIt enables you to create hassle-free GraphQL APIs without having to write Schema manually (for queries and subscriptions - i still recommend using rest for writes)\n\n## Installation\n\n### Install adnotations package in the project that holds your DbContext \n`dotnet add package HotChocolatier.Adnotations --version 1.0.0`\nor\n`NuGet\\Install-Package HotChocolatier.Adnotations -Version 1.0.0`\n\n### Install dotnet tool \n`dotnet tool install --global HotChocolatier.Tool --version 1.0.0`\n\n# How it Works\nIt generates GraphQL Schema for Query and Subscription. Example use:\n### IMPORTANT NOTE\nYou need to add `\u003cCopyLocalLockFileAssemblies\u003etrue\u003c/CopyLocalLockFileAssemblies\u003e` to your DbContext Project\nin the first propertygroup section\n\n```XML\n  \u003cPropertyGroup\u003e\n    \u003cTargetFramework\u003enet7.0\u003c/TargetFramework\u003e\n    \u003cImplicitUsings\u003eenable\u003c/ImplicitUsings\u003e\n    \u003cNullable\u003eenable\u003c/Nullable\u003e\n    \u003cCopyLocalLockFileAssemblies\u003etrue\u003c/CopyLocalLockFileAssemblies\u003e \u003c!-- Here --\u003e\n  \u003c/PropertyGroup\u003e\n```\nThen you need to build the project and call HotChocolatier with following attributes: \n```\nhotchocolatier -a E:\\Projects\\GameDesignStudio\\src\\Backend\\GameDesignStudio.Data\\bin\\Debug\\net7.0\\GameDesignStudio.Data.dll -n GameDesignStudio.GraphQL.Schema -v -o E:\\Projects\\GameDesignStudio\\src\\Backend\\GameDesignStudio.GraphQL\n```\nIf you feel lost, there's always -h that displays the manual, but here's a rundown of options:\n* -a is a dll holding the DbContext class\n* -n is a target namespace of generated schema\n* -v is used to display verbose logs\n* -o defines output directory (of course it will create its' own Schema folder with subsequent Query and Subscription folders to organize each partial classes.\n\nIt automatically names partials based on DbSet name. So example output will look like: \n\n```CSharp\n// ... inside DbContext\n [GraphQlSubscription(Authorize = true),\n GraphQlList(UseSorting = true, UseFiltering = true, UseProjection = true, Authorize = true),\n GraphQlPagedList(UseSorting = true, UseFiltering = true, UseProjection = true, Authorize = true),\n GraphQlGetById(Authorize = true)]\n    public DbSet\u003cUser\u003e Users { get; set; }\n```\n\nIn order to get the attributes you need the HotChocolatier.Adnotations package. \nIt contains following attributes: \n* GraphQLSubscription (creates subscriptions with Added and Updated Event - you need to trigger them manually from other services - see (https://chillicream.com/docs/hotchocolate/v13/defining-a-schema/subscriptions)\n* GraphQLList (exposes raw IQueryable for projections, sorting etc - of course you can configure which one you want and which one you don't want)\n* GraphQlPagedList (uses offset paging)\n* GraphQLGetById (allows to get one item by integer id)\n\nOutput for Users DbSet will look like this (File Name: Query.Users.cs): \n\n```CSharp \nusing Microsoft.EntityFrameworkCore;\nusing HotChocolate.Authorization;\nnamespace GameDesignStudio.GraphQL.Schema;\n\npublic partial class Query{\n    \n[Authorize, UseProjection, UseFiltering, UseSorting]\npublic IQueryable\u003cGameDesignStudio.Data.Model.Auth.User\u003e GetUsers([Service(ServiceKind.Synchronized)] GameDesignStudio.Data.Context.GameDesignStudioContext context)\n =\u003e context.Users;\n\n\n[Authorize, UseOffsetPaging(DefaultPageSize = 50, IncludeTotalCount = true, MaxPageSize = 1000), UseProjection, UseFiltering, UseSorting]\npublic IQueryable\u003cGameDesignStudio.Data.Model.Auth.User\u003e GetUsersWithPaging([Service(ServiceKind.Synchronized)] GameDesignStudio.Data.Context.GameDesignStudioContext context)\n =\u003e context.Users;\n\n\npublic async ValueTask\u003cGameDesignStudio.Data.Model.Auth.User?\u003e GetUser([Service(ServiceKind.Synchronized)] GameDesignStudio.Data.Context.GameDesignStudioContext context, int id)\n=\u003e await context.Users.FirstOrDefaultAsync(x =\u003e x.Id == id);\n\n\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmikstacki%2Fhotchocolatier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmikstacki%2Fhotchocolatier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmikstacki%2Fhotchocolatier/lists"}