Skip to content

Commit 6efc631

Browse files
authored
Remove DefaultErrorInfoProvider (#761)
1 parent 2a7acb5 commit 6efc631

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

samples/Samples.Server/CustomErrorInfoProvider.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
using System.Text;
22
using GraphQL.Execution;
3-
using GraphQL.Server;
43
using GraphQL.Server.Authorization.AspNetCore;
54
using Microsoft.AspNetCore.Authorization;
6-
using Microsoft.Extensions.Options;
75

86
namespace GraphQL.Samples.Server
97
{
108
/// <summary>
119
/// Custom <see cref="ErrorInfoProvider"/> implementing a dedicated error message for the sample <see cref="IAuthorizationRequirement"/>
1210
/// used in this MS article: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies
1311
/// </summary>
14-
public class CustomErrorInfoProvider : DefaultErrorInfoProvider
12+
public class CustomErrorInfoProvider : ErrorInfoProvider
1513
{
1614
private readonly IAuthorizationErrorMessageBuilder _messageBuilder;
1715

18-
public CustomErrorInfoProvider(IOptions<ErrorInfoProviderOptions> options, IAuthorizationErrorMessageBuilder messageBuilder)
19-
: base(options)
16+
public CustomErrorInfoProvider(IAuthorizationErrorMessageBuilder messageBuilder)
2017
{
2118
_messageBuilder = messageBuilder;
2219
}

src/Core/DefaultErrorInfoProvider.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Transports.AspNetCore/GraphQLHttpMiddleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ private static bool TryGetEncoding(string charset, out System.Text.Encoding enco
329329
try
330330
{
331331
// Remove at most a single set of quotes.
332-
if (charset.Length > 2 && charset[0] == '\"' && charset[charset.Length - 1] == '\"')
332+
if (charset.Length > 2 && charset[0] == '\"' && charset[^1] == '\"')
333333
{
334-
encoding = System.Text.Encoding.GetEncoding(charset.Substring(1, charset.Length - 2));
334+
encoding = System.Text.Encoding.GetEncoding(charset[1..^1]);
335335
}
336336
else
337337
{

tests/ApiApprovalTests/GraphQL.Server.Core.approved.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ namespace GraphQL.Server
88
public virtual System.Threading.Tasks.Task<GraphQL.ExecutionResult> ExecuteAsync(GraphQL.Transport.GraphQLRequest request, System.Collections.Generic.IDictionary<string, object> context, System.IServiceProvider requestServices, System.Threading.CancellationToken cancellationToken = default) { }
99
protected virtual GraphQL.ExecutionOptions GetOptions(GraphQL.Transport.GraphQLRequest request, System.Collections.Generic.IDictionary<string, object> context, System.IServiceProvider requestServices, System.Threading.CancellationToken cancellationToken) { }
1010
}
11-
public class DefaultErrorInfoProvider : GraphQL.Execution.ErrorInfoProvider
12-
{
13-
public DefaultErrorInfoProvider(Microsoft.Extensions.Options.IOptions<GraphQL.Execution.ErrorInfoProviderOptions> options) { }
14-
}
1511
[System.Obsolete]
1612
public class DefaultGraphQLExecuter<TSchema> : GraphQL.Server.IGraphQLExecuter, GraphQL.Server.IGraphQLExecuter<TSchema>
1713
where TSchema : GraphQL.Types.ISchema

tests/Transports.Subscriptions.Abstractions.Tests/Specs/ChatSpec.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ public ChatSpec()
2020
_transport = new TestableSubscriptionTransport();
2121
_transportReader = _transport.Reader as TestableReader;
2222
_transportWriter = _transport.Writer as TestableWriter;
23+
#pragma warning disable CS0618 // Type or member is obsolete
2324
_subscriptions = new SubscriptionManager(
2425
new BasicGraphQLExecuter<ChatSchema>(
2526
new ChatSchema(_chat, new DefaultServiceProvider()),
2627
new SubscriptionDocumentExecuter(),
2728
Options.Create(new GraphQLOptions { })
2829
),
2930
new NullLoggerFactory());
31+
#pragma warning restore CS0618 // Type or member is obsolete
3032

3133
_server = new SubscriptionServer(
3234
_transport,

0 commit comments

Comments
 (0)