Skip to content

Commit ca0e3bc

Browse files
committed
Initial commit
0 parents  commit ca0e3bc

File tree

18 files changed

+274
-0
lines changed

18 files changed

+274
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin/
2+
obj/
3+
/packages/
4+
riderModule.iml
5+
/_ReSharper.Caches/

.idea/.idea.GraphQLDemo/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.GraphQLDemo/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.GraphQLDemo/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.GraphQLDemo/.idea/vagrant.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.GraphQLDemo/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.EntityFrameworkCore;
2+
3+
namespace GraphQLDemo.Server.Database;
4+
5+
public class BlogContext(DbContextOptions<BlogContext> options) : DbContext(options)
6+
{
7+
public DbSet<BlogPost> BlogPosts { get; set; }
8+
9+
public static async Task Initialize(AsyncServiceScope scope)
10+
{
11+
var blogPosts = new Bogus.Faker<BlogPost>()
12+
.RuleFor(o => o.Id, f => Guid.NewGuid())
13+
.RuleFor(o => o.Title, f => "About " + f.Company.CompanyName())
14+
.RuleFor(o => o.Description, f => f.Company.CatchPhrase())
15+
.RuleFor(o => o.Text, f => f.Lorem.Text())
16+
.Generate(1000);
17+
18+
var factory = scope.ServiceProvider.GetRequiredService<IDbContextFactory<BlogContext>>();
19+
await using var database = await factory.CreateDbContextAsync();
20+
21+
await database.BlogPosts!.AddRangeAsync(blogPosts);
22+
await database.SaveChangesAsync();
23+
}
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace GraphQLDemo.Server.Database;
2+
3+
public class BlogPost
4+
{
5+
public Guid Id { get; set; }
6+
7+
public string Title { get; set; } = string.Empty;
8+
9+
public string Description { get; set; } = string.Empty;
10+
11+
public string Text { get; set; } = string.Empty;
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
11+
<PackageReference Include="Bogus" Version="35.5.1" />
12+
<PackageReference Include="HotChocolate.AspNetCore" Version="13.9.6" />
13+
<PackageReference Include="HotChocolate.Data.EntityFramework" Version="13.9.6" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.6" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using AutoMapper;
2+
using GraphQLDemo.Server.Database;
3+
using GraphQLDemo.Server.Schema.Queries;
4+
5+
namespace GraphQLDemo.Server.Profiles;
6+
7+
public sealed class BlogProfile : Profile
8+
{
9+
public BlogProfile()
10+
{
11+
CreateMap<BlogPost, BlogPostType>();
12+
}
13+
}

0 commit comments

Comments
 (0)