Feat/design time#2
Conversation
There was a problem hiding this comment.
Pull request overview
Adds EF Core design-time integration to automatically generate GraphQL DataLoader sidecar files during migrations scaffolding, and updates the generator output to better match GraphQL conventions (ignored FK scalar fields, improved notes/docs).
Changes:
- Introduce a new
Stackworx.EfCoreGraphQL.DesignTimeproject with anIMigrationsCodeGeneratorthat generates{Snapshot}.DataLoaders.g.cs+ a hash sidecar. - Update core generator to support design-time (string generation from
IModel, pass DbContext type instead of instance) and emitExtendObjectType(... IgnoreFields = ...)for redundant FK scalar fields. - Enhance many-to-many generation with explicit XML doc notes and update tests/sample outputs accordingly.
Reviewed changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Stackworx.EfCoreGraphQL.Tests/Tests.cs | Updates expectations/calls to pass DbContext type and compare entity type as string. |
| src/Stackworx.EfCoreGraphQL/TypeUtils.cs | Adds ToGraphQlFieldName helper for camelCase conversion. |
| src/Stackworx.EfCoreGraphQL/Stackworx.EfCoreGraphQL.csproj | Bumps package version to 0.0.12-alpha. |
| src/Stackworx.EfCoreGraphQL/ManyToMany.cs | Adds loader/field notes and emits XML doc summaries for generated methods. |
| src/Stackworx.EfCoreGraphQL/Generate.cs | Adds GenerateString for design-time generation and emits IgnoreFields for FK scalars. |
| src/Stackworx.EfCoreGraphQL/ForeignKeyIgnoreFields.cs | New helper to compute redundant FK scalar GraphQL field names to ignore. |
| src/Stackworx.EfCoreGraphQL/FieldExtension.cs | Changes APIs to accept DbContext type instead of instance. |
| src/Stackworx.EfCoreGraphQL/DataLoader.cs | Changes EntityType from Type to string and updates emitter + factory signatures. |
| src/Stackworx.EFCoreGraphQL.DesignTime/Stackworx.EfCoreGraphQL.DesignTime.csproj | New design-time package project definition. |
| src/Stackworx.EFCoreGraphQL.DesignTime/README.md | Adds design-time integration sample instructions. |
| src/Stackworx.EFCoreGraphQL.DesignTime/EfCoreMigrationsCodeGenerator.cs | New migrations generator writing sidecar + hash files. |
| sample/Sample/Sample.csproj | Updates EF Core packages and removes direct project reference to generator lib. |
| sample/Sample/DataLoaders.g.cs | Updates generated output (IgnoreFields + many-to-many XML docs). |
| sample/Sample.Generate/Sample.Generate.csproj | Adds reference to generator library for the console generation app. |
| sample/Sample.DesignTime/appsettings.json | New design-time sample app configuration. |
| sample/Sample.DesignTime/WebApplicationExtensions.cs | Adds seeding for design-time sample app. |
| sample/Sample.DesignTime/Types/Query.cs | Adds GraphQL query types for design-time sample app. |
| sample/Sample.DesignTime/Sample.DesignTime.csproj | New sample app wiring the design-time package. |
| sample/Sample.DesignTime/Properties/launchSettings.json | New run profile for design-time sample app. |
| sample/Sample.DesignTime/Program.cs | New design-time sample app host setup. |
| sample/Sample.DesignTime/Migrations/AppDbContextModelSnapshot.cs | New snapshot for design-time sample. |
| sample/Sample.DesignTime/Migrations/AppDbContextModelSnapshot.DataLoaders.g.hash | New hash file tracking snapshot changes. |
| sample/Sample.DesignTime/Migrations/AppDbContextModelSnapshot.DataLoaders.g.cs | New generated DataLoaders sidecar file. |
| sample/Sample.DesignTime/Migrations/20260221162418_InitialCreate.cs | Adds an (empty) migration in the sample. |
| sample/Sample.DesignTime/Migrations/20260221162418_InitialCreate.Designer.cs | Designer for the empty migration. |
| sample/Sample.DesignTime/Migrations/20260221160640_Initial.cs | Adds initial schema migration for the sample. |
| sample/Sample.DesignTime/Migrations/20260221160640_Initial.Designer.cs | Designer for the initial schema migration. |
| sample/Sample.DesignTime/DesignTimeServices.cs | Registers the custom migrations code generator for EF tooling discovery. |
| sample/Sample.DesignTime/Data/Book.cs | Sample entity. |
| sample/Sample.DesignTime/Data/Author.cs | Sample entity. |
| sample/Sample.DesignTime/Data/AppDbContextFactory.cs | Design-time DbContext factory for EF tools. |
| sample/Sample.DesignTime/Data/AppDbContext.cs | Sample DbContext model setup. |
| sample/Sample.DesignTime/.gitignore | Ignores local db folder. |
| dotnet-tools.json | Bumps dotnet-ef tool version. |
| Stackworx.EfCoreGraphQL.slnx | Adds new projects and normalizes solution entries. |
| README.md | Documents how to use the design-time integration. |
Files not reviewed (2)
- sample/Sample.DesignTime/Migrations/20260221160640_Initial.Designer.cs: Language not supported
- sample/Sample.DesignTime/Migrations/20260221162418_InitialCreate.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Design-time generation doesn't have a DbContext instance. | ||
| // The emitters currently only need entity metadata, so we can safely pass null. | ||
| // (Any future DbContext usage should be guarded.) | ||
| Generate(contextType, entity, sb, version); |
There was a problem hiding this comment.
The comment says design-time generation can “safely pass null”, but the code now passes contextType into Generate(...). Update/remove the comment so it matches the current implementation and doesn’t suggest null is expected/allowed.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
…erator.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…erator.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….DesignTime.csproj Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@cliedeman I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ed directly Co-authored-by: cliedeman <3578740+cliedeman@users.noreply.github.com>
Remove stale comment misrepresenting null usage in Generate.cs
No description provided.