Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: graphql-dotnet/server
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.1.1
Choose a base ref
...
head repository: graphql-dotnet/server
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.2.0
Choose a head ref
  • 14 commits
  • 81 files changed
  • 3 contributors

Commits on Dec 12, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    renovate-bot Mend Renovate
    Copy the full SHA
    db8484f View commit details

Commits on Dec 14, 2021

  1. Copy the full SHA
    857a178 View commit details

Commits on Dec 20, 2021

  1. Copy the full SHA
    ecc92a3 View commit details

Commits on Dec 25, 2021

  1. Copy the full SHA
    fe16988 View commit details

Commits on Dec 26, 2021

  1. Copy the full SHA
    d4090a7 View commit details
  2. Copy the full SHA
    08b16aa View commit details

Commits on Dec 27, 2021

  1. Copy the full SHA
    7d780f7 View commit details
  2. Copy the full SHA
    916ddec View commit details
  3. Copy the full SHA
    f7659c8 View commit details

Commits on Dec 28, 2021

  1. Multi-TFM approvals (#675)

    sungam3r authored Dec 28, 2021
    Copy the full SHA
    7017816 View commit details
  2. Copy the full SHA
    fe040c8 View commit details

Commits on Dec 29, 2021

  1. Auto approve API (#689)

    sungam3r authored Dec 29, 2021
    Copy the full SHA
    37fd20d View commit details

Commits on Dec 30, 2021

  1. Copy the full SHA
    bed99b0 View commit details

Commits on Jan 1, 2022

  1. Copy the full SHA
    d6b58a4 View commit details
Showing with 1,233 additions and 307 deletions.
  1. +3 −0 .github/codecov.yml
  2. +3 −2 .github/labeler.yml
  3. +2 −2 .github/workflows/build.yml
  4. +1 −1 .github/workflows/codeql-analysis.yml
  5. +2 −2 .github/workflows/publish.yml
  6. +9 −12 .github/workflows/test.yml
  7. +2 −0 .gitignore
  8. +6 −7 Directory.Build.props
  9. +10 −2 GraphQL.Server.sln
  10. +15 −9 README.md
  11. +1 −0 Tests.props
  12. +1 −1 samples/Samples.Schemas.Chat/IChat.cs
  13. +1 −1 samples/Samples.Schemas.Chat/Message.cs
  14. +1 −1 samples/Samples.Schemas.Chat/MessageType.cs
  15. +1 −1 samples/Samples.Schemas.Chat/ReceivedMessage.cs
  16. +3 −1 samples/Samples.Server/Samples.Server.csproj
  17. +15 −8 samples/Samples.Server/Startup.cs
  18. +16 −9 samples/Samples.Server/StartupWithRouting.cs
  19. +4 −4 src/All/All.csproj
  20. +1 −1 src/Authorization.AspNetCore/Authorization.AspNetCore.csproj
  21. +33 −0 src/Authorization.AspNetCore/GraphQLBuilderAuthorizationExtensions.cs
  22. +1 −1 src/Benchmarks/Benchmarks.csproj
  23. +65 −0 src/Core/BasicGraphQLExecuter.cs
  24. +2 −2 src/Core/Core.csproj
  25. +1 −0 src/Core/DefaultGraphQLExecuter.cs
  26. +44 −0 src/Core/Extensions/GraphQLBuilderCoreExtensions.cs
  27. +3 −0 src/Core/Extensions/ServiceCollectionExtensions.cs
  28. +2 −0 src/Core/GraphQLBuilder.cs
  29. +2 −0 src/Core/IGraphQLBuilder.cs
  30. +26 −1 src/Transports.AspNetCore.NewtonsoftJson/GraphQLBuilderNewtonsoftJsonExtensions.cs
  31. +11 −3 src/Transports.AspNetCore.NewtonsoftJson/GraphQLRequestDeserializer.cs
  32. +2 −3 src/Transports.AspNetCore.NewtonsoftJson/InternalGraphQLRequest.cs
  33. +2 −2 src/Transports.AspNetCore.NewtonsoftJson/Transports.AspNetCore.NewtonsoftJson.csproj
  34. +34 −1 src/Transports.AspNetCore.SystemTextJson/GraphQLBuilderSystemTextJsonExtensions.cs
  35. +4 −4 src/Transports.AspNetCore.SystemTextJson/GraphQLRequestDeserializer.cs
  36. +4 −5 src/Transports.AspNetCore.SystemTextJson/InternalGraphQLRequest.cs
  37. +2 −2 src/Transports.AspNetCore.SystemTextJson/Transports.AspNetCore.SystemTextJson.csproj
  38. +86 −0 src/Transports.AspNetCore/Extensions/GraphQLBuilderUserContextExtensions.cs
  39. +1 −1 src/Transports.AspNetCore/Transports.AspNetCore.csproj
  40. +1 −1 src/Transports.Subscriptions.Abstractions/IServerOperations.cs
  41. +1 −1 src/Transports.Subscriptions.Abstractions/ISubscriptionManager.cs
  42. +28 −11 src/Transports.Subscriptions.Abstractions/Subscription.cs
  43. +61 −11 src/Transports.Subscriptions.Abstractions/SubscriptionManager.cs
  44. +4 −1 src/Transports.Subscriptions.Abstractions/SubscriptionServer.cs
  45. +3 −3 src/Transports.Subscriptions.Abstractions/Transports.Subscriptions.Abstractions.csproj
  46. +15 −2 src/Transports.Subscriptions.WebSockets/Extensions/GraphQLBuilderWebSocketsExtensions.cs
  47. +2 −1 src/Transports.Subscriptions.WebSockets/GraphQLWebSocketsMiddleware.cs
  48. +1 −1 src/Transports.Subscriptions.WebSockets/Transports.Subscriptions.WebSockets.csproj
  49. +9 −2 src/Transports.Subscriptions.WebSockets/WebSocketConnection.cs
  50. +23 −2 src/Transports.Subscriptions.WebSockets/WebSocketConnectionFactory.cs
  51. +16 −14 src/Transports.Subscriptions.WebSockets/WebSocketReaderPipeline.cs
  52. +7 −1 src/Transports.Subscriptions.WebSockets/WebSocketTransport.cs
  53. +1 −1 src/Ui.Altair/Ui.Altair.csproj
  54. +14 −0 src/Ui.GraphiQL/GraphiQLOptions.cs
  55. +3 −1 src/Ui.GraphiQL/Internal/GraphiQLPageModel.cs
  56. +171 −128 src/Ui.GraphiQL/Internal/graphiql.cshtml
  57. +1 −1 src/Ui.GraphiQL/Ui.GraphiQL.csproj
  58. +1 −1 src/Ui.Playground/Ui.Playground.csproj
  59. +1 −1 src/Ui.Voyager/Ui.Voyager.csproj
  60. +62 −8 tests/ApiApprovalTests/ApiApprovalTests.cs
  61. +2 −1 tests/ApiApprovalTests/ApiApprovalTests.csproj
  62. +4 −0 tests/ApiApprovalTests/GraphQL.Server.Authorization.AspNetCore.approved.txt
  63. +24 −0 tests/ApiApprovalTests/GraphQL.Server.Core.approved.txt
  64. +2 −0 tests/ApiApprovalTests/GraphQL.Server.Transports.AspNetCore.NewtonsoftJson.approved.txt
  65. +2 −0 tests/ApiApprovalTests/GraphQL.Server.Transports.AspNetCore.SystemTextJson.approved.txt
  66. +11 −0 tests/ApiApprovalTests/GraphQL.Server.Transports.AspNetCore.approved.txt
  67. +9 −4 tests/ApiApprovalTests/GraphQL.Server.Transports.Subscriptions.Abstractions.approved.txt
  68. +9 −3 tests/ApiApprovalTests/GraphQL.Server.Transports.Subscriptions.WebSockets.approved.txt
  69. +2 −0 tests/ApiApprovalTests/GraphQL.Server.Ui.GraphiQL.approved.txt
  70. +1 −1 tests/Authorization.AspNetCore.Tests/Authorization.AspNetCore.Tests.csproj
  71. +46 −5 tests/Authorization.AspNetCore.Tests/AuthorizationValidationRuleTests.cs
  72. +4 −4 tests/Samples.Server.Tests/ResponseTests.cs
  73. +1 −1 tests/Samples.Server.Tests/Samples.Server.Tests.csproj
  74. +104 −0 tests/Transports.AspNetCore.Tests/NewtonsoftJsonTests.cs
  75. +104 −0 tests/Transports.AspNetCore.Tests/SystemTextJsonTests.cs
  76. +37 −0 tests/Transports.AspNetCore.Tests/TestHttpRequest.cs
  77. +18 −0 tests/Transports.AspNetCore.Tests/Transports.AspNetCore.Tests.csproj
  78. +2 −5 tests/Transports.Subscriptions.Abstractions.Tests/Specs/ChatSpec.cs
  79. +1 −1 tests/Transports.Subscriptions.Abstractions.Tests/Transports.Subscriptions.Abstractions.Tests.csproj
  80. +2 −0 tests/Transports.Subscriptions.WebSockets.Tests/TestStartup.cs
  81. +1 −1 tests/Transports.Subscriptions.WebSockets.Tests/Transports.Subscriptions.WebSockets.Tests.csproj
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://docs.codecov.com/docs/codecov-yaml
comment:
behavior: new
5 changes: 3 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
test:
- tests/**/*
test: ['tests/**/*', '!tests/ApiApprovalTests/**/*.txt']

CI:
- .github/workflows/**/*
- .github/dependabot.yml
- .github/labeler.yml
- .github/codecov.yml

code style:
- .editorconfig
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core 5.0 SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
dotnet-version: "6.0.x"
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
dotnet-version: "6.0.x"

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -27,10 +27,10 @@ jobs:
version="${github_ref:10}"
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Setup .NET Core 5.0 SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
dotnet-version: "6.0.x"
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
21 changes: 9 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ on:
- .github/workflows/**
- "*.props"
- "*.targets"
- "*.sln"
# Upload code coverage results when PRs are merged
push:
branches:
@@ -39,17 +40,13 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup .NET Core 3.1 SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Setup .NET Core 5.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
dotnet-version: |
3.1.x
5.0.x
6.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -59,8 +56,8 @@ jobs:
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
dotnet tool install -g dotnet-format --version 6.0.243104 --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
dotnet format --check --fix-whitespace || (echo "Run 'dotnet format' to fix formatting issues" && exit 1)
dotnet format --check -v diag --fix-style warn --fix-analyzers warn || (echo "Run 'dotnet format' to fix formatting issues" && exit 1)
dotnet format --no-restore --verify-no-changes -v diag --severity warn whitespace || (echo "Run 'dotnet format' to fix whitespace issues" && exit 1)
dotnet format --no-restore --verify-no-changes -v diag --severity warn analyzers || (echo "Run 'dotnet format' to fix analyzers issues" && exit 1)
- name: Build solution [Release]
run: dotnet build --no-restore -c Release
- name: Build solution [Debug]
@@ -71,7 +68,7 @@ jobs:
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: codecov/codecov-action@v2.1.0
with:
files: .coverage/GraphQL.Server.Authorization.AspNetCore.Tests/coverage.net5.opencover.xml,.coverage/GraphQL.Server.Samples.Server.Tests/coverage.netcoreapp3.1.opencover.xml,.coverage/GraphQL.Server.Transports.Subscriptions.Abstractions.Tests/coverage.net5.opencover.xml,.coverage/GraphQL.Server.Transports.Subscriptions.WebSockets.Tests/coverage.net5.opencover.xml
files: .coverage/GraphQL.Server.Authorization.AspNetCore.Tests/coverage.net5.opencover.xml,.coverage/GraphQL.Server.Samples.Server.Tests/coverage.netcoreapp3.1.opencover.xml,.coverage/GraphQL.Server.Transports.Subscriptions.Abstractions.Tests/coverage.net5.opencover.xml,.coverage/GraphQL.Server.Transports.Subscriptions.WebSockets.Tests/coverage.net5.opencover.xml,.coverage/GraphQL.Server.Transports.AspNetCore.Tests/coverage.net5.opencover.xml

buildcheck:
needs:
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,5 @@

[Oo]bj/
[Bb]in/

*.received.txt
13 changes: 6 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<VersionPrefix>5.1.0-preview</VersionPrefix>
<VersionPrefix>5.2.0-preview</VersionPrefix>
<LangVersion>latest</LangVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo.64x64.png</PackageIcon>
@@ -20,18 +20,17 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<NoWarn>$(NoWarn);1591</NoWarn> <!--TODO: temporary solution-->
<PackageReadmeFile Condition="'$(IsPackable)' == 'true'">README.md</PackageReadmeFile>

<AssemblyName>GraphQL.Server.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>GraphQL.Server.$(MSBuildProjectName)</RootNamespace>
<PackageId>GraphQL.Server.$(MSBuildProjectName)</PackageId>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\assets\logo.64x64.png" Pack="true" PackagePath="\" Condition="'$(IsPackable)' == 'true'" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" Condition="'$(IsPackable)' == 'true'"/>
<ItemGroup Condition="'$(IsPackable)' == 'true'">
<None Include="..\..\assets\logo.64x64.png" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

</Project>
12 changes: 10 additions & 2 deletions GraphQL.Server.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transports.Subscriptions.WebSockets", "src\Transports.Subscriptions.WebSockets\Transports.Subscriptions.WebSockets.csproj", "{4DF1CB8E-30AA-4281-9056-D49FDBF4C496}"
EndProject
@@ -60,6 +60,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "src\Benchmark
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{592C7A03-4F0C-40C2-86F9-C7A4E03504A7}"
ProjectSection(SolutionItems) = preProject
.github\codecov.yml = .github\codecov.yml
.github\dependabot.yml = .github\dependabot.yml
.github\labeler.yml = .github\labeler.yml
EndProjectSection
@@ -78,6 +79,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiApprovalTests", "tests\A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "All", "src\All\All.csproj", "{B39BC064-B96A-442D-89A0-79B750F88ADD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transports.AspNetCore.Tests", "tests\Transports.AspNetCore.Tests\Transports.AspNetCore.Tests.csproj", "{1857A25B-C4A3-4332-9077-3F2516AC6059}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -164,6 +167,10 @@ Global
{B39BC064-B96A-442D-89A0-79B750F88ADD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B39BC064-B96A-442D-89A0-79B750F88ADD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B39BC064-B96A-442D-89A0-79B750F88ADD}.Release|Any CPU.Build.0 = Release|Any CPU
{1857A25B-C4A3-4332-9077-3F2516AC6059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1857A25B-C4A3-4332-9077-3F2516AC6059}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1857A25B-C4A3-4332-9077-3F2516AC6059}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1857A25B-C4A3-4332-9077-3F2516AC6059}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -184,6 +191,7 @@ Global
{C1FCE2C8-F6EF-48DA-ADD8-9159516D03DA} = {BBD07745-C962-4D2D-B302-6DA1BCC2FF43}
{17945A3F-4C80-43B3-BBD7-6FE0EA107799} = {592C7A03-4F0C-40C2-86F9-C7A4E03504A7}
{9F1A96BC-FF87-427F-8284-5A0670CA596C} = {BBD07745-C962-4D2D-B302-6DA1BCC2FF43}
{1857A25B-C4A3-4332-9077-3F2516AC6059} = {BBD07745-C962-4D2D-B302-6DA1BCC2FF43}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3FC7FA59-E938-453C-8C4A-9D5635A9489A}
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -127,11 +127,14 @@ public void ConfigureServices(IServiceCollection services)
// Add GraphQL services and configure options
services
.AddSingleton<IChat, Chat>()
.AddSingleton<ChatSchema>()
.AddGraphQL((options, provider) =>
.AddSingleton<ChatSchema>();

MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
.AddServer(true)
.ConfigureExecution(options =>
{
options.EnableMetrics = Environment.IsDevelopment();
var logger = provider.GetRequiredService<ILogger<Startup>>();
var logger = options.RequestServices.GetRequiredService<ILogger<Startup>>();
options.UnhandledExceptionDelegate = ctx => logger.LogError("{Error} occurred", ctx.OriginalException.Message);
})
// Add required services for GraphQL request/response de/serialization
@@ -140,7 +143,7 @@ public void ConfigureServices(IServiceCollection services)
.AddErrorInfoProvider(opt => opt.ExposeExceptionStackTrace = Environment.IsDevelopment())
.AddWebSockets() // Add required services for web socket support
.AddDataLoader() // Add required services for DataLoader support
.AddGraphTypes(typeof(ChatSchema)) // Add all IGraphType implementors in assembly which ChatSchema exists
.AddGraphTypes(typeof(ChatSchema).Assembly) // Add all IGraphType implementors in assembly which ChatSchema exists
}

public void Configure(IApplicationBuilder app)
@@ -177,11 +180,14 @@ public void ConfigureServices(IServiceCollection services)
services
.AddRouting()
.AddSingleton<IChat, Chat>()
.AddSingleton<ChatSchema>()
.AddGraphQL((options, provider) =>
.AddSingleton<ChatSchema>();

MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
.AddServer(true)
.ConfigureExecution(options =>
{
options.EnableMetrics = Environment.IsDevelopment();
var logger = provider.GetRequiredService<ILogger<Startup>>();
var logger = options.RequestServices.GetRequiredService<ILogger<Startup>>();
options.UnhandledExceptionDelegate = ctx => logger.LogError("{Error} occurred", ctx.OriginalException.Message);
})
// It is required when both GraphQL HTTP and GraphQL WebSockets middlewares are mapped to the same endpoint (by default 'graphql').
@@ -192,7 +198,7 @@ public void ConfigureServices(IServiceCollection services)
.AddErrorInfoProvider(opt => opt.ExposeExceptionStackTrace = Environment.IsDevelopment())
.AddWebSockets() // Add required services for web socket support
.AddDataLoader() // Add required services for DataLoader support
.AddGraphTypes(typeof(ChatSchema)); // Add all IGraphType implementors in assembly which ChatSchema exists
.AddGraphTypes(typeof(ChatSchema).Assembly); // Add all IGraphType implementors in assembly which ChatSchema exists
}

public void Configure(IApplicationBuilder app)
@@ -202,7 +208,7 @@ public void Configure(IApplicationBuilder app)

// this is required for ASP.NET Core routing
app.UseRouting();

app.UseEndpoints(endpoints =>
{
// map websocket middleware for ChatSchema at default path /graphql
1 change: 1 addition & 0 deletions Tests.props
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.19" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.10" Condition="'$(TargetFramework)' == 'net5'" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" Condition="'$(TargetFramework)' == 'net6'" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/Samples.Schemas.Chat/IChat.cs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ public Message AddMessage(ReceivedMessage message)
return AddMessage(new Message
{
Content = message.Content,
SentAt = message.SentAt,
SentAt = message.SentAt ?? DateTime.UtcNow,
From = new MessageFrom
{
DisplayName = displayName,
2 changes: 1 addition & 1 deletion samples/Samples.Schemas.Chat/Message.cs
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@ public class Message

public string Content { get; set; }

public DateTime SentAt { get; set; }
public DateTime? SentAt { get; set; }
}
}
2 changes: 1 addition & 1 deletion samples/Samples.Schemas.Chat/MessageType.cs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ public class MessageType : ObjectGraphType<Message>
public MessageType()
{
Field(o => o.Content);
Field(o => o.SentAt, type: typeof(DateGraphType));
Field(o => o.SentAt, type: typeof(DateTimeGraphType));
Field(o => o.Sub);
Field(o => o.From, false, typeof(MessageFromType)).Resolve(ResolveFrom);
}
2 changes: 1 addition & 1 deletion samples/Samples.Schemas.Chat/ReceivedMessage.cs
Original file line number Diff line number Diff line change
@@ -8,6 +8,6 @@ public class ReceivedMessage

public string Content { get; set; }

public DateTime SentAt { get; set; }
public DateTime? SentAt { get; set; }
}
}
4 changes: 3 additions & 1 deletion samples/Samples.Server/Samples.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net5;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6;net5;netcoreapp3.1</TargetFrameworks>
<AssemblyName>GraphQL.Samples.Server</AssemblyName>
<RootNamespace>GraphQL.Samples.Server</RootNamespace>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL.SystemReactive" Version="4.6.1" />
<PackageReference Include="Serilog.AspNetCore" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="4.6.1" />
</ItemGroup>

<ItemGroup>
23 changes: 15 additions & 8 deletions samples/Samples.Server/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Collections.Generic;
using GraphQL.DataLoader;
using GraphQL.Execution;
using GraphQL.Samples.Schemas.Chat;
using GraphQL.Server;
using GraphQL.Server.Ui.Altair;
using GraphQL.Server.Ui.GraphiQL;
using GraphQL.Server.Ui.Playground;
using GraphQL.Server.Ui.Voyager;
using GraphQL.SystemReactive;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@@ -29,20 +32,24 @@ public Startup(IConfiguration configuration, IWebHostEnvironment environment)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services
.AddSingleton<IChat, Chat>()
.AddSingleton<ChatSchema>()
.AddGraphQL((options, provider) =>
services.AddSingleton<IChat, Chat>();

MicrosoftDI.GraphQLBuilderExtensions.AddGraphQL(services)
.AddSubscriptionDocumentExecuter()
.AddServer(true)
.AddSchema<ChatSchema>()
.ConfigureExecution(options =>
{
options.EnableMetrics = Environment.IsDevelopment();
var logger = provider.GetRequiredService<ILogger<Startup>>();
var logger = options.RequestServices.GetRequiredService<ILogger<Startup>>();
options.UnhandledExceptionDelegate = ctx => logger.LogError("{Error} occurred", ctx.OriginalException.Message);
})
.AddSystemTextJson(deserializerSettings => { }, serializerSettings => { })
.AddErrorInfoProvider<CustomErrorInfoProvider>(opt => opt.ExposeExceptionStackTrace = Environment.IsDevelopment())
.AddSystemTextJson()
.AddErrorInfoProvider<CustomErrorInfoProvider>()
.Configure<ErrorInfoProviderOptions>(opt => opt.ExposeExceptionStackTrace = Environment.IsDevelopment())
.AddWebSockets()
.AddDataLoader()
.AddGraphTypes(typeof(ChatSchema));
.AddGraphTypes(typeof(ChatSchema).Assembly);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Loading