Backend (.NET 10): - EventFlow CQRS/Event Sourcing with PostgreSQL - GraphQL.NET API with mutations and queries - Custom ReadModelSqlGenerator for snake_case PostgreSQL columns - Hangfire for background job processing - Integration tests with isolated test databases Frontend (React/Vite): - Initial project structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Books.Api.Domain.Companies;
|
|
using Books.Api.EventFlow.Repositories;
|
|
using Books.Api.GraphQL.Types;
|
|
using GraphQL;
|
|
using GraphQL.Types;
|
|
|
|
namespace Books.Api.GraphQL.Queries;
|
|
|
|
public class BooksQuery : ObjectGraphType
|
|
{
|
|
public BooksQuery()
|
|
{
|
|
Name = "Query";
|
|
Description = "Root query for the Books API";
|
|
|
|
// companies: [CompanyType]
|
|
Field<ListGraphType<CompanyType>>("companies")
|
|
.Description("Get all companies")
|
|
.ResolveAsync(async ctx =>
|
|
{
|
|
var repository = ctx.RequestServices!.GetRequiredService<ICompanyRepository>();
|
|
return await repository.GetAllAsync(ctx.CancellationToken);
|
|
});
|
|
|
|
// company(id: ID!): CompanyType
|
|
Field<CompanyType>("company")
|
|
.Description("Get a company by ID")
|
|
.Argument<NonNullGraphType<IdGraphType>>("id", "The company ID")
|
|
.ResolveAsync(async ctx =>
|
|
{
|
|
var id = ctx.GetArgument<string>("id");
|
|
var repository = ctx.RequestServices!.GetRequiredService<ICompanyRepository>();
|
|
var companies = await repository.GetByIds([CompanyId.With(id)], ctx.CancellationToken);
|
|
return companies.FirstOrDefault();
|
|
});
|
|
}
|
|
}
|