-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to run .net8 and opinionated changes #27
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(ImplicitUsings)' == 'enable'"> | ||
<Using Include="Server" /> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.6.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" /> | ||
<PackageReference Include="Snapshooter.Xunit" Version="0.13.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../Server/Server.csproj"/> | ||
<ProjectReference Include="../Server/Server.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{2FE5A0A3-9A07-42E0-B6D3-486E17167C2D}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{6DC201A7-45E1-4223-8E6B-779E6520859E}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server.Tests", "Server.Tests", "{BE4BAB9F-3D26-4D64-AB1C-F37EDEBF5545}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server.Tests", "Server.Tests\Server.Tests.csproj", "{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E} = {2FE5A0A3-9A07-42E0-B6D3-486E17167C2D} | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8} = {BE4BAB9F-3D26-4D64-AB1C-F37EDEBF5545} | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{2FE5A0A3-9A07-42E0-B6D3-486E17167C2D}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{6DC201A7-45E1-4223-8E6B-779E6520859E}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server.Tests", "Server.Tests", "{BE4BAB9F-3D26-4D64-AB1C-F37EDEBF5545}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Tests", "Server.Tests\Server.Tests.csproj", "{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{6DC201A7-45E1-4223-8E6B-779E6520859E} = {2FE5A0A3-9A07-42E0-B6D3-486E17167C2D} | ||
{AFD5A3E8-9B16-452E-A11D-A688CAA9D8E8} = {BE4BAB9F-3D26-4D64-AB1C-F37EDEBF5545} | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using ApolloGraphQL.HotChocolate.Federation.Two; | ||
using HotChocolate.Execution.Configuration; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection; | ||
|
||
public static class GraphServiceCollectionExtensions | ||
{ | ||
public static IRequestExecutorBuilder AddGraphQLServices(this IRequestExecutorBuilder builder) | ||
{ | ||
return builder | ||
.AddApolloFederationV2(schemaConfiguration: schema => | ||
{ | ||
schema.Contact( | ||
name: "Thing Server Team", | ||
url: "https://myteam.slack.com/archives/teams-chat-room-url", | ||
description: "send urgent issues to [#oncall](https://yourteam.slack.com/archives/oncall)"); | ||
}) | ||
.AddType<ContactDirectiveType>() | ||
.AddQueryType<Query>() | ||
.AddMutationType<Mutation>() | ||
.RegisterService<Data>(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,21 @@ | ||
using ApolloGraphQL.HotChocolate.Federation.Two; | ||
using HotChocolate.AspNetCore; | ||
using HotChocolate.Execution; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
var builder = WebApplication.CreateSlimBuilder(args); | ||
|
||
builder.Services | ||
.AddSingleton<Data>(); | ||
|
||
builder.Services | ||
.AddGraphQLServer() | ||
.AddApolloFederationV2(new CustomSchema()) | ||
.AddType<ContactDirectiveType>() | ||
.AddQueryType<Query>() | ||
.AddMutationType<Mutation>() | ||
.RegisterService<Data>() | ||
.AddGraphQLServices() | ||
.AddHttpRequestInterceptor<RouterAuthInterceptor>(); | ||
|
||
var port = Environment.GetEnvironmentVariable("PORT") ?? "4001"; | ||
builder.WebHost.UseUrls($"http://*:{port}"); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapGraphQL(); | ||
var bananaCakePop = app.MapBananaCakePop("/"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a template for a new project, I think we should have the
|
||
bananaCakePop.WithOptions(new GraphQLToolOptions { GraphQLEndpoint = "/graphql" }); | ||
|
||
if (args.Length > 1 && args[0] == "schema" && args[1] == "export") | ||
_ = app.RunWithGraphQLCommandsAsync(args); | ||
else | ||
app.Run(); | ||
app.RunWithGraphQLCommands(args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is way nicer! |
||
|
||
public sealed class RouterAuthInterceptor : DefaultHttpRequestInterceptor | ||
{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love the opinionated launchSettings. I wanted this but wasn't quite sure of the current standards, lots of dotnet releases since I was with Xamarin. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:49905", | ||
"sslPort": 44344 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "graphql", | ||
"applicationUrl": "http://localhost:5239", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "graphql", | ||
"applicationUrl": "https://localhost:7037;http://localhost:5239", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "graphql", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(ImplicitUsings)' == 'enable'"> | ||
<Using Include="Server" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="HotChocolate.AspNetCore" Version="13.6.1" /> | ||
<PackageReference Include="HotChocolate.AspNetCore.CommandLine" Version="13.6.1" /> | ||
<PackageReference Include="ApolloGraphQL.HotChocolate.Federation" Version="1.3.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure that the template will listen on the
PORT
environment variable for deployments like Railway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simplify this to: