Skip to content

Commit fab4691

Browse files
authored
Remove ThrowIfCancellationRequested from VisitAsync (#337)
1 parent 98020b9 commit fab4691

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/GraphQLParser.Tests/Visitors/ASTVisitorTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ public void ASTVisitor_Should_Throw_On_Unknown_Node()
3333
}
3434

3535
[Fact]
36-
public void ASTVisitor_Should_Respect_CancellationToken()
36+
public void ASTVisitor_Should_Pass_CancellationToken()
3737
{
3838
var document = "scalar JSON".Parse();
3939
var visitor = new MyVisitor();
4040
using var cts = new CancellationTokenSource(500);
4141
var context = new Context { CancellationToken = cts.Token };
42+
context.CancellationToken.ThrowIfCancellationRequested();
4243

4344
Should.Throw<OperationCanceledException>(() => visitor.VisitAsync(document, context).GetAwaiter().GetResult());
4445
}
@@ -48,6 +49,7 @@ private class MyVisitor : ASTVisitor<Context>
4849
protected override async ValueTask VisitScalarTypeDefinitionAsync(GraphQLScalarTypeDefinition scalarTypeDefinition, Context context)
4950
{
5051
await Task.Delay(700);
52+
context.CancellationToken.ThrowIfCancellationRequested();
5153
await base.VisitScalarTypeDefinitionAsync(scalarTypeDefinition, context);
5254
}
5355
}

src/GraphQLParser/Visitors/ASTVisitor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,6 @@ protected virtual async ValueTask VisitInputObjectTypeExtensionAsync(GraphQLInpu
595595
/// <param name="context">Context passed into all INodeVisitor.VisitXXX methods.</param>
596596
public virtual ValueTask VisitAsync(ASTNode? node, TContext context)
597597
{
598-
context.CancellationToken.ThrowIfCancellationRequested();
599-
600598
return node == null
601599
? default
602600
: node switch

0 commit comments

Comments
 (0)