Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions templates/gateway-managed/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Michael Staib",
"classifications": ["Web", "GraphQL"],
"identity": "HotChocolate.Template.ManagedGateway",
"sourceName": "HotChocolate.Template.Gateway",
"name": "GraphQL Managed Gateway",
"shortName": "graphql-managed-gateway",
"defaultName": "GraphQL Gateway",
"description": "",
"preferNameDirectory": true,
"tags": {
"language": "C#",
"type": "project"
},
"symbols": {
"Framework": {
"type": "parameter",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net8.0",
"description": "Target .NET 8"
},
{
"choice": "net9.0",
"description": "Target .NET 9"
},
{
"choice": "net10.0",
"description": "Target .NET 10"
}
],
"replaces": "net8.0",
"defaultValue": "net8.0"
}
},
"postActions": [
{
"condition": "(!skipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}
21 changes: 21 additions & 0 deletions templates/gateway-managed/HotChocolate.Template.Gateway.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ChilliCream.Nitro.Fusion" Version="15.0.0" />
<PackageReference Include="ChilliCream.Nitro.Telemetry" Version="15.0.0" />
<PackageReference Include="HotChocolate.Fusion.AspNetCore" Version="14.0.0-preview.build.0" />
<!-- TODO: This should be based on the target framework selection -->
<PackageReference Include="Microsoft.AspNetCore.HeaderPropagation" Version="9.0.8" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />

</ItemGroup>

</Project>
50 changes: 50 additions & 0 deletions templates/gateway-managed/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services
.AddHeaderPropagation(c =>
{
c.Headers.Add("GraphQL-Preflight");
c.Headers.Add("Authorization");
});

builder.Services
.AddHttpClient("fusion")
.AddHeaderPropagation();

builder.Services
.AddGraphQLGatewayServer()
.ConfigureFromCloud(options =>
{
options.ApiId = "YOUR_API_ID";
options.Stage = "prod";
options.ApiKey = "YOUR_API_KEY";
})
// TODO: This needs to go
.CoreBuilder.AddInstrumentation();

builder.Services.AddNitroTelemetry(options =>
{
options.ApiId = "YOUR_API_ID";
options.Stage = "prod";
options.ApiKey = "YOUR_API_KEY";
});

builder.Services
.AddOpenTelemetry()
.WithTracing(builder =>
{
builder.AddHttpClientInstrumentation();
builder.AddAspNetCoreInstrumentation();
builder.AddNitroExporter();
})
.WithLogging(builder =>
{
builder.AddNitroExporter();
});

var app = builder.Build();

app.UseHeaderPropagation();
app.MapGraphQL();

app.Run();
14 changes: 14 additions & 0 deletions templates/gateway-managed/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "http://localhost:5098/graphql",
"applicationUrl": "http://localhost:5098",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions templates/gateway-managed/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions templates/gateway-managed/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
52 changes: 52 additions & 0 deletions templates/server-managed/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Michael Staib",
"classifications": ["Web", "GraphQL"],
"identity": "HotChocolate.Template.ManagedServer",
"sourceName": "HotChocolate.Template.Server",
"name": "GraphQL Managed Server",
"shortName": "graphql-managed",
"defaultName": "GraphQL",
"description": "",
"preferNameDirectory": true,
"tags": {
"language": "C#",
"type": "project"
},
"symbols": {
"Framework": {
"type": "parameter",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net8.0",
"description": "Target .NET 8"
},
{
"choice": "net9.0",
"description": "Target .NET 9"
},
{
"choice": "net10.0",
"description": "Target .NET 10"
}
],
"replaces": "net8.0",
"defaultValue": "net8.0"
}
},
"postActions": [
{
"condition": "(!skipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}
26 changes: 26 additions & 0 deletions templates/server-managed/HotChocolate.Template.Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup Condition="'$(ImplicitUsings)' == 'enable'">
<Using Include="HotChocolate.Template.Server" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ChilliCream.Nitro" Version="15.0.0" />
<PackageReference Include="HotChocolate.AspNetCore" Version="14.0.0-preview.build.0" />
<PackageReference Include="HotChocolate.AspNetCore.CommandLine" Version="14.0.0-preview.build.0" />
<PackageReference Include="HotChocolate.Types.Analyzers" Version="14.0.0-preview.build.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions templates/server-managed/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var builder = WebApplication.CreateBuilder(args);

builder.AddGraphQL()
.AddTypes()
.AddInstrumentation()
.AddNitro(options =>
{
options.ApiId = "YOUR_API_ID";
options.Stage = "prod";
options.ApiKey = "YOUR_API_KEY";
});

builder.Services
.AddNitroTelemetry(options =>
{
options.ApiId = "YOUR_API_ID";
options.Stage = "prod";
options.ApiKey = "YOUR_API_KEY";
});

builder.Services
.AddOpenTelemetry()
.WithTracing(builder =>
{
builder.AddAspNetCoreInstrumentation();
builder.AddNitroExporter();
})
.WithLogging(builder =>
{
builder.AddNitroExporter();
});

var app = builder.Build();

app.MapGraphQL();

app.RunWithGraphQLCommands(args);
1 change: 1 addition & 0 deletions templates/server-managed/Properties/ModuleInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: Module("Types")]
14 changes: 14 additions & 0 deletions templates/server-managed/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "http://localhost:5095/graphql",
"applicationUrl": "http://localhost:5095",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
3 changes: 3 additions & 0 deletions templates/server-managed/Types/Author.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace HotChocolate.Template.Server.Types;

public record Author(string Name);
3 changes: 3 additions & 0 deletions templates/server-managed/Types/Book.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace HotChocolate.Template.Server.Types;

public record Book(string Title, Author Author);
8 changes: 8 additions & 0 deletions templates/server-managed/Types/Query.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace HotChocolate.Template.Server.Types;

[QueryType]
public static class Query
{
public static Book GetBook()
=> new Book("C# in depth.", new Author("Jon Skeet"));
}
8 changes: 8 additions & 0 deletions templates/server-managed/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions templates/server-managed/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading