diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs
index 94805db7d03..0afcda85c05 100644
--- a/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs
+++ b/src/HotChocolate/Core/src/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs
@@ -144,13 +144,13 @@ public IDisposable ExecuteOperation(IRequestContext context)
return new AggregateActivityScope(scopes);
}
- public IDisposable ExecuteStream(IRequestContext context)
+ public IDisposable ExecuteStream(IOperation operation)
{
var scopes = new IDisposable[_listeners.Length];
for (var i = 0; i < _listeners.Length; i++)
{
- scopes[i] = _listeners[i].ExecuteStream(context);
+ scopes[i] = _listeners[i].ExecuteStream(operation);
}
return new AggregateActivityScope(scopes);
diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs
index d80018bc2c7..fc39201baf3 100644
--- a/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs
+++ b/src/HotChocolate/Core/src/Execution/Instrumentation/ExecutionDiagnosticEventListener.cs
@@ -82,7 +82,7 @@ public virtual IDisposable ExecuteOperation(IRequestContext context)
=> EmptyScope;
///
- public virtual IDisposable ExecuteStream(IRequestContext context)
+ public virtual IDisposable ExecuteStream(IOperation operation)
=> EmptyScope;
public virtual IDisposable ExecuteDeferredTask()
diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs
index 7b06e8b8348..19d4d9958d2 100644
--- a/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs
+++ b/src/HotChocolate/Core/src/Execution/Instrumentation/IExecutionDiagnosticEvents.cs
@@ -163,16 +163,14 @@ public interface IExecutionDiagnosticEvents
/// The ExecuteStream scope will run longer then the ExecuteOperation scope.
/// The ExecuteOperation scope is completed once the initial operation is executed.
/// All deferred elements will be executed and delivered within the ExecuteStream scope.
- /// The passed in context is polled and can only be used at the initialization of the scope.
///
- ///
- /// The request context encapsulates all GraphQL-specific information about an
- /// individual GraphQL request.
+ ///
+ /// The operation that is being streamed.
///
///
/// A scope that will be disposed when the execution has finished.
///
- IDisposable ExecuteStream(IRequestContext context);
+ IDisposable ExecuteStream(IOperation operation);
///
/// Called when starting to execute a deferred part an operation
diff --git a/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs
index 465d252d4e7..c8bec0f573c 100644
--- a/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs
+++ b/src/HotChocolate/Core/src/Execution/Instrumentation/NoopExecutionDiagnosticEvents.cs
@@ -44,11 +44,9 @@ public void OperationComplexityResult(
public IDisposable CompileOperation(IRequestContext context) => this;
- public IDisposable BuildQueryPlan(IRequestContext context) => this;
-
public IDisposable ExecuteOperation(IRequestContext context) => this;
- public IDisposable ExecuteStream(IRequestContext context) => this;
+ public IDisposable ExecuteStream(IOperation operation) => this;
public IDisposable ExecuteDeferredTask() => this;
diff --git a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs
index 7d1b63db8d7..1b4ef0d14ba 100644
--- a/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs
+++ b/src/HotChocolate/Core/src/Execution/Processing/DeferredWorkScheduler.cs
@@ -1,6 +1,8 @@
+using System;
using System.Collections.Generic;
using System.Threading;
using HotChocolate.Execution.DependencyInjection;
+using HotChocolate.Execution.Instrumentation;
using static HotChocolate.Execution.QueryResultBuilder;
namespace HotChocolate.Execution.Processing;
@@ -64,22 +66,36 @@ public void Complete(DeferredExecutionTaskResult result)
=> StateOwner.State.Complete(result);
public IAsyncEnumerable CreateResultStream(IQueryResult initialResult)
- => new DeferResultStream(initialResult, StateOwner);
+ => new DeferResultStream(
+ initialResult,
+ StateOwner,
+ _parentContext.Operation,
+ _parentContext.DiagnosticEvents);
private class DeferResultStream : IAsyncEnumerable
{
private readonly IQueryResult _initialResult;
private readonly DeferredWorkStateOwner _stateOwner;
-
- public DeferResultStream(IQueryResult initialResult, DeferredWorkStateOwner stateOwner)
+ private readonly IOperation _operation;
+ private readonly IExecutionDiagnosticEvents _diagnosticEvents;
+
+ public DeferResultStream(
+ IQueryResult initialResult,
+ DeferredWorkStateOwner stateOwner,
+ IOperation operation,
+ IExecutionDiagnosticEvents diagnosticEvents)
{
_initialResult = FromResult(initialResult).SetHasNext(true).Create();
_stateOwner = stateOwner;
+ _operation = operation;
+ _diagnosticEvents = diagnosticEvents;
}
public async IAsyncEnumerator GetAsyncEnumerator(
CancellationToken cancellationToken = default)
{
+ var span = _diagnosticEvents.ExecuteStream(_operation);
+
try
{
@@ -102,6 +118,7 @@ public async IAsyncEnumerator GetAsyncEnumerator(
finally
{
_stateOwner.Dispose();
+ span.Dispose();
}
}
}
diff --git a/src/HotChocolate/Core/src/Execution/Processing/Tasks/ResolverTaskFactory.cs b/src/HotChocolate/Core/src/Execution/Processing/Tasks/ResolverTaskFactory.cs
index ce51e67318d..d87c4ee698b 100644
--- a/src/HotChocolate/Core/src/Execution/Processing/Tasks/ResolverTaskFactory.cs
+++ b/src/HotChocolate/Core/src/Execution/Processing/Tasks/ResolverTaskFactory.cs
@@ -20,8 +20,8 @@ public static ObjectResult EnqueueResolverTasks(
Path path,
IImmutableDictionary scopedContext)
{
- var responseIndex = 0;
var selectionsCount = selectionSet.Selections.Count;
+ var responseIndex = selectionsCount;
var parentResult = operationContext.Result.RentObject(selectionsCount);
var scheduler = operationContext.Scheduler;
var pathFactory = operationContext.PathFactory;
@@ -35,7 +35,13 @@ public static ObjectResult EnqueueResolverTasks(
{
ref var selectionSpace = ref ((SelectionSet)selectionSet).GetSelectionsReference();
- for (var i = 0; i < selectionsCount; i++)
+ // we are iterating reverse so that in the case of a mutation the first
+ // synchronous root selection is executed first, since the work scheduler
+ // is using two stacks one for parallel work an one for synchronous work.
+ // the scheduler this tries to schedule new work first.
+ // coincidentally we can use that to schedule a mutation so that we honor the spec
+ // guarantees while executing efficient.
+ for (var i = selectionsCount - 1; i >= 0; i--)
{
ref var selection = ref Unsafe.Add(ref selectionSpace, i);
@@ -46,7 +52,7 @@ public static ObjectResult EnqueueResolverTasks(
selection,
parent,
parentResult,
- responseIndex++,
+ --responseIndex,
pathFactory.Append(path, selection.ResponseName),
scopedContext));
}
diff --git a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/AutomapperTests.cs b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/AutomapperTests.cs
index a0196b1c770..46aad27b892 100644
--- a/src/HotChocolate/Data/test/Data.AutoMapper.Tests/AutomapperTests.cs
+++ b/src/HotChocolate/Data/test/Data.AutoMapper.Tests/AutomapperTests.cs
@@ -95,11 +95,11 @@ public class ProjectToTests
public async Task Execute_ManyToOne()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -121,11 +121,11 @@ public async Task Execute_ManyToOne()
public async Task Execute_ManyToOne_Deep()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -156,11 +156,11 @@ query Test {
public async Task Execute_OneToOne()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -181,11 +181,11 @@ public async Task Execute_OneToOne()
public async Task Execute_OneToOne_Deep()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -210,11 +210,11 @@ query Test {
public async Task Execute_Derived_CompleteSelectionSet()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -234,11 +234,11 @@ ... on StandardMemberDto { standard }
public async Task Execute_Derived_PartialSelectionSet()
{
// arrange
- IRequestExecutor tester = await CreateSchema();
+ var tester = await CreateSchema();
// act
// assert
- IExecutionResult res1 = await tester.ExecuteAsync(
+ var res1 = await tester.ExecuteAsync(
QueryRequestBuilder.New()
.SetQuery(
@"
@@ -267,11 +267,11 @@ public async ValueTask CreateSchema()
mc.AddProfile(new AuthorProfile());
});
- IMapper mapper = mapperConfig.CreateMapper();
+ var mapper = mapperConfig.CreateMapper();
services.AddSingleton(sp =>
{
// abusing the mapper factory to add to the database. You didnt see this.
- BloggingContext context =
+ var context =
sp.GetRequiredService>().CreateDbContext();
context.Database.EnsureCreated();
context.Blogs.AddRange(_blogEntries);
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/AuthorFixture.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/AuthorFixture.cs
index 9868d55d69f..9367e5bfb46 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/AuthorFixture.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/AuthorFixture.cs
@@ -30,7 +30,7 @@ public class AuthorFixture : IDisposable
public AuthorFixture()
{
_fileName = Guid.NewGuid().ToString("N") + ".db";
- BookContext context = new ServiceCollection()
+ var context = new ServiceCollection()
.AddDbContext(
b => b.UseSqlite("Data Source=" + _fileName))
.AddGraphQL()
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkExecutableTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkExecutableTests.cs
index a620f08f2c8..a92fa483182 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkExecutableTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkExecutableTests.cs
@@ -20,7 +20,7 @@ public void Extensions_Should_ReturnEntityFrameworkExecutable_When_DBSet()
{
// arrange
// act
- IExecutable executable = _context.Authors.AsExecutable();
+ var executable = _context.Authors.AsExecutable();
// assert
Assert.IsType>(executable);
@@ -32,7 +32,7 @@ public void Extensions_Should_ReturnEntityFrameworkExecutable_When_Queryable()
{
// arrange
// act
- IExecutable executable = _context
+ var executable = _context
.Authors
.AsQueryable()
.AsEntityFrameworkExecutable();
@@ -47,7 +47,7 @@ public void Extensions_Should_ReturnEntityFrameworkExecutable_When_Queryable()
public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync()
{
// arrange
- IExecutable executable = _context
+ var executable = _context
.Authors
.AsExecutable();
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs
index 1a7de41185c..f637924e2dc 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/EntityFrameworkResolverCompilerIntegrationTests.cs
@@ -48,7 +48,7 @@ public async Task Resolver_Pipeline_With_Request_DbContext_Is_Created()
using AuthorFixture authorFixture = new();
- using IServiceScope scope = new ServiceCollection()
+ using var scope = new ServiceCollection()
.AddScoped(_ => authorFixture.Context)
.AddGraphQL()
.AddQueryType()
@@ -58,7 +58,7 @@ public async Task Resolver_Pipeline_With_Request_DbContext_Is_Created()
.BuildServiceProvider()
.CreateScope();
- IExecutionResult result = await scope.ServiceProvider.ExecuteRequestAsync(
+ var result = await scope.ServiceProvider.ExecuteRequestAsync(
QueryRequestBuilder.New()
.SetQuery("{ books { title } }")
.SetServices(scope.ServiceProvider)
@@ -74,7 +74,7 @@ public async Task Resolver_Pipeline_With_Field_DbContext_Is_Created()
using AuthorFixture authorFixture = new();
- await using ServiceProvider service = new ServiceCollection()
+ await using var service = new ServiceCollection()
.AddScoped(_ => authorFixture.Context)
.AddGraphQL()
.AddQueryType()
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/IntegrationTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/IntegrationTests.cs
index 7e4dbe2dfb5..f28b46ff3af 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/IntegrationTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/IntegrationTests.cs
@@ -26,7 +26,7 @@ public IntegrationTests(AuthorFixture authorFixture)
public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -39,7 +39,7 @@ public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -56,7 +56,7 @@ public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync()
public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -71,7 +71,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -88,7 +88,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault()
public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -106,7 +106,7 @@ public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -123,7 +123,7 @@ public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne()
public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -141,7 +141,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -158,7 +158,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero()
public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -173,7 +173,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -190,7 +190,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault()
public async Task ExecuteAsync_Should_ReturnNull_When_FirstOrDefaultZero()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -208,7 +208,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_FirstOrDefaultZero()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -226,7 +226,7 @@ public async Task OffsetPagingExecutable()
{
// arrange
// act
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase("Data Source=EF.OffsetPagingExecutable.db"))
.AddGraphQL()
@@ -237,7 +237,7 @@ public async Task OffsetPagingExecutable()
.BuildRequestExecutorAsync();
// assert
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPagingExecutable {
items {
@@ -258,7 +258,7 @@ public async Task OffsetPagingExecutable()
public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -274,7 +274,7 @@ public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync_AsyncEnume
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -291,7 +291,7 @@ public async Task ExecuteAsync_Should_ReturnAllItems_When_ToListAsync_AsyncEnume
public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -310,7 +310,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault_AsyncEnum
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -327,7 +327,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_SingleOrDefault_AsyncEnum
public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -345,7 +345,7 @@ public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne_Async
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -362,7 +362,7 @@ public async Task ExecuteAsync_Should_Fail_When_SingleOrDefaultMoreThanOne_Async
public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -380,7 +380,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero_AsyncE
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -397,7 +397,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_SingleOrDefaultZero_AsyncE
public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -415,7 +415,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault_AsyncEnume
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
@@ -432,7 +432,7 @@ public async Task ExecuteAsync_Should_OnlyOneItem_When_FirstOrDefault_AsyncEnume
public async Task ExecuteAsync_Should_ReturnNull_When_FirstOrDefaultZero_AsyncEnumerable()
{
// arrange
- IRequestExecutor executor = await new ServiceCollection()
+ var executor = await new ServiceCollection()
.AddGraphQL()
.AddFiltering()
.AddSorting()
@@ -450,7 +450,7 @@ public async Task ExecuteAsync_Should_ReturnNull_When_FirstOrDefaultZero_AsyncEn
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"
{
executable {
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/Query.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/Query.cs
index 8fd1854c131..b4c5b8fedeb 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/Query.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/Query.cs
@@ -175,7 +175,7 @@ protected override void Configure(IObjectTypeDescriptor descriptor)
.UseDbContext()
.Resolve(ctx =>
{
- BookContext context = ctx.DbContext();
+ var context = ctx.DbContext();
return context.Books;
});
@@ -184,7 +184,7 @@ protected override void Configure(IObjectTypeDescriptor descriptor)
.Field("booksWithMissingContext")
.Resolve(ctx =>
{
- BookContext context = ctx.DbContext();
+ var context = ctx.DbContext();
return context.Books;
});
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlCursorCursorPagingIntegrationTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlCursorCursorPagingIntegrationTests.cs
index 4c43c15f28f..6c308ba9822 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlCursorCursorPagingIntegrationTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlCursorCursorPagingIntegrationTests.cs
@@ -22,7 +22,7 @@ public async Task Simple_StringList_Default_Items()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -51,7 +51,7 @@ public async Task No_Boundaries_Set()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -80,7 +80,7 @@ public async Task Attribute_Simple_StringList_Default_Items()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -109,7 +109,7 @@ public async Task Simple_StringList_First_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -138,7 +138,7 @@ public async Task Attribute_Simple_StringList_First_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -167,7 +167,7 @@ public async Task Simple_StringList_First_2_After()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -196,7 +196,7 @@ public async Task Attribute_Simple_StringList_First_2_After()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -225,7 +225,7 @@ public async Task Simple_StringList_Global_DefaultItem_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -254,7 +254,7 @@ public async Task Attribute_Simple_StringList_Global_DefaultItem_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -283,7 +283,7 @@ public async Task TotalCount_Should_Be_Correct()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteCursorTestBase.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteCursorTestBase.cs
index 0c2f9ebceac..22706bcaaeb 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteCursorTestBase.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteCursorTestBase.cs
@@ -18,9 +18,9 @@ private DatabaseContext BuildContext(
dbContext.Database.EnsureDeleted();
dbContext.Database.EnsureCreated();
- DbSet? set = dbContext.Set();
+ var set = dbContext.Set();
- foreach (TResult result in results)
+ foreach (var result in results)
{
set.Add(result);
dbContext.SaveChanges();
@@ -34,14 +34,14 @@ private DatabaseContext BuildContext(
protected IRequestExecutor CreateSchema(TEntity[] entities)
where TEntity : class
{
- ISchemaBuilder builder = SchemaBuilder.New()
+ var builder = SchemaBuilder.New()
.AddQueryType(
c => c.Name("Query")
.Field("root")
.UseDbContext>()
.Resolve(ctx =>
{
- DatabaseContext context =
+ var context =
ctx.DbContext>();
BuildContext(context, entities);
return context.Data;
@@ -68,7 +68,7 @@ protected IRequestExecutor CreateSchema(TEntity[] entities)
IncludeTotalCount = true
}));
- ISchema schema = builder.Create();
+ var schema = builder.Create();
return new ServiceCollection()
.Configure(
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteOffsetTestBase.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteOffsetTestBase.cs
index 672dddbd875..42b72a92c07 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteOffsetTestBase.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlLiteOffsetTestBase.cs
@@ -18,9 +18,9 @@ private DatabaseContext BuildContext(
dbContext.Database.EnsureDeleted();
dbContext.Database.EnsureCreated();
- DbSet? set = dbContext.Set();
+ var set = dbContext.Set();
- foreach (TResult result in results)
+ foreach (var result in results)
{
set.Add(result);
dbContext.SaveChanges();
@@ -34,14 +34,14 @@ private DatabaseContext BuildContext(
protected IRequestExecutor CreateSchema(TEntity[] entities)
where TEntity : class
{
- ISchemaBuilder builder = SchemaBuilder.New()
+ var builder = SchemaBuilder.New()
.AddQueryType(
c => c.Name("Query")
.Field("root")
.UseDbContext>()
.Resolve(ctx =>
{
- DatabaseContext context =
+ var context =
ctx.DbContext>();
BuildContext(context, entities);
return context.Data;
@@ -68,7 +68,7 @@ protected IRequestExecutor CreateSchema(TEntity[] entities)
IncludeTotalCount = true
}));
- ISchema schema = builder.Create();
+ var schema = builder.Create();
return new ServiceCollection()
.Configure(
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlOffsetPagingIntegrationTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlOffsetPagingIntegrationTests.cs
index ed21948ccde..3a8b41afc60 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlOffsetPagingIntegrationTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/SqlOffsetPagingIntegrationTests.cs
@@ -22,7 +22,7 @@ public async Task Simple_StringList_Default_Items()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -45,7 +45,7 @@ public async Task No_Boundaries_Set()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -68,7 +68,7 @@ public async Task Attribute_Simple_StringList_Default_Items()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -91,7 +91,7 @@ public async Task Simple_StringList_Skip_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -114,7 +114,7 @@ public async Task Attribute_Simple_StringList_Skip_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -137,7 +137,7 @@ public async Task Simple_StringList_Skip_2_After()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -160,7 +160,7 @@ public async Task Attribute_Simple_StringList_Skip_2_After()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -183,7 +183,7 @@ public async Task Simple_StringList_Global_DefaultItem_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -206,7 +206,7 @@ public async Task Attribute_Simple_StringList_Global_DefaultItem_2()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
@@ -229,7 +229,7 @@ public async Task TotalCount_Should_Be_Correct()
{
Snapshot.FullName();
- IRequestExecutor executor = CreateSchema(Data);
+ var executor = CreateSchema(Data);
await executor
.ExecuteAsync(@"
diff --git a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/UseDbContextTests.cs b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/UseDbContextTests.cs
index 2b668871d10..8c9c08a1476 100644
--- a/src/HotChocolate/Data/test/Data.EntityFramework.Tests/UseDbContextTests.cs
+++ b/src/HotChocolate/Data/test/Data.EntityFramework.Tests/UseDbContextTests.cs
@@ -27,21 +27,21 @@ public async Task Execute_Queryable()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.SaveChangesAsync();
}
// act
- IExecutionResult result = await executor.ExecuteAsync("{ authors { name } }");
+ var result = await executor.ExecuteAsync("{ authors { name } }");
// assert
result.ToJson().MatchSnapshot();
@@ -63,21 +63,21 @@ public async Task Execute_Queryable_Task()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.SaveChangesAsync();
}
// act
- IExecutionResult result = await executor.ExecuteAsync("{ authors { name } }");
+ var result = await executor.ExecuteAsync("{ authors { name } }");
// assert
result.ToJson().MatchSnapshot();
@@ -99,21 +99,21 @@ public async Task Execute_Queryable_ValueTask()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.SaveChangesAsync();
}
// act
- IExecutionResult result = await executor.ExecuteAsync("{ authors { name } }");
+ var result = await executor.ExecuteAsync("{ authors { name } }");
// assert
result.ToJson().MatchSnapshot();
@@ -135,14 +135,14 @@ public async Task Execute_Queryable_OffsetPaging_TotalCount()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -150,7 +150,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -184,14 +184,14 @@ public async Task Execute_Queryable_OffsetPaging_TotalCount_Task()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -199,7 +199,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -233,14 +233,14 @@ public async Task Execute_Queryable_OffsetPaging_TotalCount_QueryableExtensions(
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -248,7 +248,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
queryableExtensionsOffset {
items {
@@ -282,14 +282,14 @@ public async Task Execute_Queryable_OffsetPaging_TotalCount_ValueTask()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -297,7 +297,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -331,14 +331,14 @@ public async Task Execute_Queryable_OffsetPaging()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -346,7 +346,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -379,14 +379,14 @@ public async Task Execute_Queryable_OffsetPaging_Task()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -394,7 +394,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -427,14 +427,14 @@ public async Task Execute_Queryable_OffsetPaging_ValueTask()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -442,7 +442,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorOffsetPaging {
items {
@@ -475,21 +475,21 @@ public async Task Execute_Single()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.SaveChangesAsync();
}
// act
- IExecutionResult result = await executor.ExecuteAsync("{ author { name } }");
+ var result = await executor.ExecuteAsync("{ author { name } }");
// assert
result.ToJson().MatchSnapshot();
@@ -512,7 +512,7 @@ async Task CreateSchema() =>
.BuildSchemaAsync();
// assert
- SchemaException exception = await Assert.ThrowsAsync(CreateSchema);
+ var exception = await Assert.ThrowsAsync(CreateSchema);
exception.Errors.First().Message.MatchSnapshot();
}
@@ -521,7 +521,7 @@ public async Task Infer_Schema_From_IQueryable_Fields()
{
// arrange
// act
- ISchema schema =
+ var schema =
await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase(CreateConnectionString()))
@@ -541,7 +541,7 @@ public async Task Infer_Schema_From_IQueryable_Task_Fields()
{
// arrange
// act
- ISchema schema =
+ var schema =
await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase(CreateConnectionString()))
@@ -561,7 +561,7 @@ public async Task Infer_Schema_From_IQueryable_ValueTask_Fields()
{
// arrange
// act
- ISchema schema =
+ var schema =
await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase(CreateConnectionString()))
@@ -580,7 +580,7 @@ public async Task Infer_Schema_From_IQueryable_ValueTask_Fields()
public async Task DbContext_ResolverExtension()
{
// arrange
- IRequestExecutor executor =
+ var executor =
await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase(CreateConnectionString()))
@@ -589,7 +589,7 @@ public async Task DbContext_ResolverExtension()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
books {
id
@@ -604,7 +604,7 @@ public async Task DbContext_ResolverExtension()
public async Task DbContext_ResolverExtension_Missing_DbContext()
{
// arrange
- IRequestExecutor executor =
+ var executor =
await new ServiceCollection()
.AddPooledDbContextFactory(
b => b.UseInMemoryDatabase(CreateConnectionString()))
@@ -614,7 +614,7 @@ public async Task DbContext_ResolverExtension_Missing_DbContext()
.BuildRequestExecutorAsync();
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
booksWithMissingContext {
id
@@ -641,14 +641,14 @@ public async Task Execute_Queryable_CursorPaging_TotalCount()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -656,7 +656,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
@@ -690,14 +690,14 @@ public async Task Execute_Queryable_CursorPaging_TotalCount_Task()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -705,7 +705,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
@@ -739,14 +739,14 @@ public async Task Execute_Queryable_CursorPaging_TotalCount_QueryableExtensions(
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -754,7 +754,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
queryableExtensionsCursor {
nodes {
@@ -788,14 +788,14 @@ public async Task Execute_Queryable_CursorPaging_TotalCount_ValueTask()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -803,7 +803,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
@@ -837,14 +837,14 @@ public async Task Execute_Queryable_CursorPaging()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -852,7 +852,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
@@ -885,14 +885,14 @@ public async Task Execute_Queryable_CursorPaging_Task()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -900,7 +900,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
@@ -933,14 +933,14 @@ public async Task Execute_Queryable_CursorPaging_ValueTask()
.Services
.BuildServiceProvider();
- IRequestExecutor executor =
+ var executor =
await services.GetRequiredService()
.GetRequestExecutorAsync();
- IDbContextFactory contextFactory =
+ var contextFactory =
services.GetRequiredService>();
- await using (BookContext context = contextFactory.CreateDbContext())
+ await using (var context = contextFactory.CreateDbContext())
{
await context.Authors.AddAsync(new Author { Name = "foo" });
await context.Authors.AddAsync(new Author { Name = "bar" });
@@ -948,7 +948,7 @@ await services.GetRequiredService()
}
// act
- IExecutionResult result = await executor.ExecuteAsync(
+ var result = await executor.ExecuteAsync(
@"query Test {
authorCursorPaging {
nodes {
diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs
index 471f729ed83..e827720c4d7 100644
--- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs
+++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs
@@ -29,7 +29,7 @@ public override IDisposable ExecuteBatch(
return EmptyScope;
}
- Activity? activity = Source.StartActivity();
+ var activity = Source.StartActivity();
if (activity is null)
{
diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs
index 5a314087709..db2e29e8716 100644
--- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs
+++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs
@@ -5,6 +5,7 @@
using HotChocolate.Diagnostics.Scopes;
using HotChocolate.Execution;
using HotChocolate.Execution.Instrumentation;
+using HotChocolate.Execution.Processing;
using HotChocolate.Resolvers;
using OpenTelemetry.Trace;
using static HotChocolate.Diagnostics.ContextKeys;
@@ -102,7 +103,7 @@ public override IDisposable ParseDocument(IRequestContext context)
return EmptyScope;
}
- Activity? activity = Source.StartActivity();
+ var activity = Source.StartActivity();
if (activity is null)
{
@@ -134,7 +135,7 @@ public override IDisposable ValidateDocument(IRequestContext context)
return EmptyScope;
}
- Activity? activity = Source.StartActivity();
+ var activity = Source.StartActivity();
if (activity is null)
{
@@ -154,7 +155,7 @@ public override void ValidationErrors(IRequestContext context, IReadOnlyList err
{
var activity = (Activity)value!;
- foreach (IError error in errors)
+ foreach (var error in errors)
{
_enricher.EnrichParserErrors(context, error, activity);
}
@@ -143,7 +143,7 @@ public override IDisposable FormatHttpResponse(HttpContext context, IQueryResult
return EmptyScope;
}
- Activity? activity = HotChocolateActivitySource.Source.StartActivity();
+ var activity = HotChocolateActivitySource.Source.StartActivity();
if (activity is null)
{
diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs
index 4c9b568be28..b82ad491152 100644
--- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs
+++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs
@@ -25,7 +25,7 @@ public static IDisposable CaptureActivities(out object activities)
if (a.Parent is null &&
a.OperationName.EqualsOrdinal("ExecuteHttpRequest") &&
- lookup.TryGetValue(rootActivity, out OrderedDictionary? parentData))
+ lookup.TryGetValue(rootActivity, out var parentData))
{
RegisterActivity(a, parentData);
lookup[a] = (OrderedDictionary)a.GetCustomProperty("test.data")!;
diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs
index 4289b0fb851..46a13b5b172 100644
--- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs
+++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs
@@ -20,7 +20,7 @@ protected override Task> LoadBatchAsync(
{
var dict = new Dictionary();
- foreach (string key in keys)
+ foreach (var key in keys)
{
dict.Add(key, key);
}
diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs
index 7d0b630ac6f..fd6ac0b216f 100644
--- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs
+++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs
@@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
-using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
+using HotChocolate.AspNetCore.Tests.Utilities;
using Snapshooter.Xunit;
using Xunit;
using static HotChocolate.Diagnostics.ActivityTestHelper;
@@ -25,7 +25,7 @@ public async Task Http_Post_SingleRequest_GetHeroName_Default()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer();
+ using var server = CreateInstrumentedServer();
// act
await server.PostAsync(new ClientQueryRequest
@@ -49,7 +49,7 @@ public async Task Http_Post_SingleRequest_GetHeroName()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o => o.Scopes = ActivityScopes.All);
// act
@@ -74,7 +74,7 @@ public async Task Http_Get_SingleRequest_GetHeroName()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o => o.Scopes = ActivityScopes.All);
// act
@@ -99,7 +99,7 @@ public async Task Http_Post_variables_are_not_automatically_added_to_activities(
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o => o.Scopes = ActivityScopes.All);
// act
@@ -125,7 +125,7 @@ public async Task Http_Post_add_variables_to_http_activity()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o =>
{
o.Scopes = ActivityScopes.All;
@@ -155,7 +155,7 @@ public async Task Http_Post_add_query_to_http_activity()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o =>
{
o.Scopes = ActivityScopes.All;
@@ -185,7 +185,7 @@ public async Task Http_Post_with_extensions_map()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o => o.Scopes = ActivityScopes.All);
// act
@@ -212,12 +212,12 @@ public async Task Http_Get_SDL_download()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
+ using var server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
var url = TestServerExtensions.CreateUrl("/graphql?sdl");
var request = new HttpRequestMessage(HttpMethod.Get, url);
// act
- HttpResponseMessage response = await server.CreateClient().SendAsync(request);
+ var response = await server.CreateClient().SendAsync(request);
// assert
await response.Content.ReadAsStringAsync();
@@ -233,7 +233,7 @@ public async Task Http_Post_capture_deferred_response()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
+ using var server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
// act
await server.PostRawAsync(new ClientQueryRequest
@@ -262,7 +262,7 @@ public async Task Http_Post_ensure_list_path_is_correctly_built()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
+ using var server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
// act
await server.PostRawAsync(new ClientQueryRequest
@@ -297,7 +297,7 @@ public async Task Http_Post_parser_error()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
+ using var server = CreateInstrumentedServer(o => o.Scopes = ActivityScopes.All);
// act
await server.PostRawAsync(new ClientQueryRequest
@@ -332,7 +332,7 @@ public async Task Parsing_error_when_rename_root_is_activated()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o =>
{
o.Scopes = ActivityScopes.All;
@@ -359,7 +359,7 @@ public async Task Validation_error_when_rename_root_is_activated()
using (CaptureActivities(out var activities))
{
// arrange
- using TestServer server = CreateInstrumentedServer(
+ using var server = CreateInstrumentedServer(
o =>
{
o.Scopes = ActivityScopes.All;
diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap
index 5aa6ff98547..cb9f0925278 100644
--- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap
+++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap
@@ -139,57 +139,59 @@
"Value": "OK"
}
],
- "event": []
- },
- {
- "OperationName": "ExecuteStream",
- "DisplayName": "ExecuteStream",
- "Status": "Unset",
- "tags": [],
- "event": []
+ "event": [],
+ "activities": [
+ {
+ "OperationName": "ResolveFieldValue",
+ "DisplayName": "/hero/id",
+ "Status": "Ok",
+ "tags": [
+ {
+ "Key": "graphql.selection.name",
+ "Value": "id"
+ },
+ {
+ "Key": "graphql.selection.type",
+ "Value": "ID!"
+ },
+ {
+ "Key": "graphql.selection.path",
+ "Value": "/hero/id"
+ },
+ {
+ "Key": "graphql.selection.hierarchy",
+ "Value": "/hero/id"
+ },
+ {
+ "Key": "graphql.selection.field.name",
+ "Value": "id"
+ },
+ {
+ "Key": "graphql.selection.field.coordinate",
+ "Value": "Droid.id"
+ },
+ {
+ "Key": "graphql.selection.field.declaringType",
+ "Value": "Droid"
+ },
+ {
+ "Key": "otel.status_code",
+ "Value": "OK"
+ }
+ ],
+ "event": []
+ }
+ ]
}
]
}
]
},
{
- "OperationName": "ResolveFieldValue",
- "DisplayName": "/hero/id",
- "Status": "Ok",
- "tags": [
- {
- "Key": "graphql.selection.name",
- "Value": "id"
- },
- {
- "Key": "graphql.selection.type",
- "Value": "ID!"
- },
- {
- "Key": "graphql.selection.path",
- "Value": "/hero/id"
- },
- {
- "Key": "graphql.selection.hierarchy",
- "Value": "/hero/id"
- },
- {
- "Key": "graphql.selection.field.name",
- "Value": "id"
- },
- {
- "Key": "graphql.selection.field.coordinate",
- "Value": "Droid.id"
- },
- {
- "Key": "graphql.selection.field.declaringType",
- "Value": "Droid"
- },
- {
- "Key": "otel.status_code",
- "Value": "OK"
- }
- ],
+ "OperationName": "ExecuteStream",
+ "DisplayName": "ExecuteStream",
+ "Status": "Unset",
+ "tags": [],
"event": []
}
]
diff --git a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/ArrayFilterTests.cs b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/ArrayFilterTests.cs
index 940cb6ac0bc..bc17e27cd5f 100644
--- a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/ArrayFilterTests.cs
+++ b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/ArrayFilterTests.cs
@@ -9,243 +9,242 @@
using HotChocolate.Execution;
using Snapshooter.Xunit;
-namespace HotChocolate.Types.Filters
+namespace HotChocolate.Types.Filters;
+
+[Obsolete]
+public class ArrayFilterTests
+ : IClassFixture
{
- [Obsolete]
- public class ArrayFilterTests
- : IClassFixture
+ private readonly MongoResource _mongoResource;
+
+ public ArrayFilterTests(MongoResource mongoResource)
{
- private readonly MongoResource _mongoResource;
+ _mongoResource = mongoResource;
+ }
- public ArrayFilterTests(MongoResource mongoResource)
+ [Fact]
+ public async Task Array_Filter_On_Scalar_Types()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton>(sp =>
+ {
+ var database = _mongoResource.CreateDatabase();
+ return database.GetCollection("col");
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .BindRuntimeType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
+
+ var collection = services.GetRequiredService>();
+
+ await collection.InsertOneAsync(new Foo
{
- _mongoResource = mongoResource;
- }
+ BarCollection = new List { "a", "b", "c" },
+ BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
+ Bars = new[] { "d", "e", "f" },
+ Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
+ Quux = "abc"
+ });
+
+ var schema = SchemaBuilder.New()
+ .AddQueryType()
+ .AddServices(services)
+ .BindClrType()
+ .Create();
+
+ var request = QueryRequestBuilder.New()
+ .SetQuery(
+ "{" +
+ "foos(where: { bars_some: { element: \"e\" } }) { bars } " +
+ "}")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.MatchSnapshot();
+ }
- [Fact]
- public async Task Array_Filter_On_Scalar_Types()
- {
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
- {
- IMongoDatabase database = _mongoResource.CreateDatabase();
- return database.GetCollection("col");
- })
- .AddGraphQL()
- .AddQueryType()
- .BindRuntimeType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IMongoCollection collection = services.GetRequiredService>();
-
- await collection.InsertOneAsync(new Foo
+ [Fact]
+ public async Task Array_Filter_On_Objects_Types()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton>(sp =>
{
- BarCollection = new List { "a", "b", "c" },
- BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
- Bars = new[] { "d", "e", "f" },
- Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
- Quux = "abc"
- });
-
- ISchema schema = SchemaBuilder.New()
- .AddQueryType()
- .AddServices(services)
- .BindClrType()
- .Create();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery(
- "{" +
- "foos(where: { bars_some: { element: \"e\" } }) { bars } " +
- "}")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
-
- [Fact]
- public async Task Array_Filter_On_Objects_Types()
+ var database = _mongoResource.CreateDatabase();
+ return database.GetCollection("col");
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .BindRuntimeType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
+
+ var collection = services.GetRequiredService>();
+
+ await collection.InsertOneAsync(new Foo
{
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
- {
- IMongoDatabase database = _mongoResource.CreateDatabase();
- return database.GetCollection("col");
- })
- .AddGraphQL()
- .AddQueryType()
- .BindRuntimeType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IMongoCollection collection = services.GetRequiredService>();
-
- await collection.InsertOneAsync(new Foo
- {
- BarCollection = new List { "a", "b", "c" },
- BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
- Bars = new[] { "d", "e", "f" },
- Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
- Quux = "abc"
- });
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery(
- "{" +
- "a: foos(where: { bazs_some: { quux: \"c\" } }) { bars } " +
- "}")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ BarCollection = new List { "a", "b", "c" },
+ BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
+ Bars = new[] { "d", "e", "f" },
+ Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
+ Quux = "abc"
+ });
+
+ var request = QueryRequestBuilder.New()
+ .SetQuery(
+ "{" +
+ "a: foos(where: { bazs_some: { quux: \"c\" } }) { bars } " +
+ "}")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.MatchSnapshot();
+ }
- [Fact]
- public async Task Collection_Filter_On_Scalar_Types()
- {
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
- {
- IMongoDatabase database = _mongoResource.CreateDatabase();
- return database.GetCollection("col");
- })
- .AddGraphQL()
- .AddQueryType()
- .BindRuntimeType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IMongoCollection collection = services.GetRequiredService>();
-
- await collection.InsertOneAsync(new Foo
+ [Fact]
+ public async Task Collection_Filter_On_Scalar_Types()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton>(sp =>
{
- BarCollection = new List { "a", "b", "c" },
- BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
- Bars = new[] { "d", "e", "f" },
- Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
- Quux = "abc"
- });
-
- ISchema schema = SchemaBuilder.New()
- .AddQueryType()
- .AddServices(services)
- .BindClrType()
- .Create();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery(
- "{" +
- "foos(where: { barCollection_some: { element: \"b\" } }) { bars } " +
- "}")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
-
- [Fact]
- public async Task Collection_Filter_On_Objects_Types()
+ var database = _mongoResource.CreateDatabase();
+ return database.GetCollection("col");
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .BindRuntimeType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
+
+ var collection = services.GetRequiredService>();
+
+ await collection.InsertOneAsync(new Foo
{
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
- {
- IMongoDatabase database = _mongoResource.CreateDatabase();
- return database.GetCollection("col");
- })
- .AddGraphQL()
- .AddQueryType()
- .BindRuntimeType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IMongoCollection collection = services.GetRequiredService>();
-
- await collection.InsertOneAsync(new Foo
- {
- BarCollection = new List { "a", "b", "c" },
- BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
- Bars = new[] { "d", "e", "f" },
- Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
- Quux = "abc"
- });
-
- ISchema schema = SchemaBuilder.New()
- .AddQueryType()
- .AddServices(services)
- .BindClrType()
- .Create();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery(
- "{" +
- "a: foos(where: { bazCollection_some: { quux: \"a\" } }) { bars } " +
- "}")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ BarCollection = new List { "a", "b", "c" },
+ BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
+ Bars = new[] { "d", "e", "f" },
+ Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
+ Quux = "abc"
+ });
+
+ var schema = SchemaBuilder.New()
+ .AddQueryType()
+ .AddServices(services)
+ .BindClrType()
+ .Create();
+
+ var request = QueryRequestBuilder.New()
+ .SetQuery(
+ "{" +
+ "foos(where: { barCollection_some: { element: \"b\" } }) { bars } " +
+ "}")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.MatchSnapshot();
+ }
- public class QueryType : ObjectType
- {
- protected override void Configure(IObjectTypeDescriptor descriptor)
+ [Fact]
+ public async Task Collection_Filter_On_Objects_Types()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton>(sp =>
{
- descriptor.Name("Query");
- descriptor.Field("foos")
- .Type>>()
- .UseFiltering>()
- .Resolve(ctx => ctx.Service>().AsQueryable());
- }
- }
-
- public class Foo
+ var database = _mongoResource.CreateDatabase();
+ return database.GetCollection("col");
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .BindRuntimeType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
+
+ var collection = services.GetRequiredService>();
+
+ await collection.InsertOneAsync(new Foo
{
- [GraphQLType(typeof(NonNullType))]
- public ObjectId Id { get; set; }
- public string[] Bars { get; set; }
- public Baz[] Bazs { get; set; }
- public ICollection BarCollection { get; set; }
- public ICollection BazCollection { get; set; }
- public string Quux { get; set; }
- }
+ BarCollection = new List { "a", "b", "c" },
+ BazCollection = new List { new Baz { Quux = "a" }, new Baz { Quux = "b" } },
+ Bars = new[] { "d", "e", "f" },
+ Bazs = new[] { new Baz { Quux = "c" }, new Baz { Quux = "d" } },
+ Quux = "abc"
+ });
+
+ var schema = SchemaBuilder.New()
+ .AddQueryType()
+ .AddServices(services)
+ .BindClrType()
+ .Create();
+
+ var request = QueryRequestBuilder.New()
+ .SetQuery(
+ "{" +
+ "a: foos(where: { bazCollection_some: { quux: \"a\" } }) { bars } " +
+ "}")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.MatchSnapshot();
+ }
- public class Baz
+ public class QueryType : ObjectType
+ {
+ protected override void Configure(IObjectTypeDescriptor descriptor)
{
- public string Quux { get; set; }
+ descriptor.Name("Query");
+ descriptor.Field("foos")
+ .Type>>()
+ .UseFiltering>()
+ .Resolve(ctx => ctx.Service>().AsQueryable());
}
}
+
+ public class Foo
+ {
+ [GraphQLType(typeof(NonNullType))]
+ public ObjectId Id { get; set; }
+ public string[] Bars { get; set; }
+ public Baz[] Bazs { get; set; }
+ public ICollection BarCollection { get; set; }
+ public ICollection BazCollection { get; set; }
+ public string Quux { get; set; }
+ }
+
+ public class Baz
+ {
+ public string Quux { get; set; }
+ }
}
diff --git a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/HotChocolate.Types.Filters.Mongo.Tests.csproj b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/HotChocolate.Types.Filters.Mongo.Tests.csproj
index 1092ac1a6ac..95692a4096f 100644
--- a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/HotChocolate.Types.Filters.Mongo.Tests.csproj
+++ b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/HotChocolate.Types.Filters.Mongo.Tests.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/MongoFilterTests.cs b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/MongoFilterTests.cs
index b0e57b163e1..135736485c8 100644
--- a/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/MongoFilterTests.cs
+++ b/src/HotChocolate/Filters/test/Types.Filters.Mongo.Tests/MongoFilterTests.cs
@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using HotChocolate.Execution;
-using HotChocolate.Types.Relay;
using Microsoft.Extensions.DependencyInjection;
using MongoDB.Bson;
using MongoDB.Driver;
@@ -9,281 +8,273 @@
using Squadron;
using Xunit;
-namespace HotChocolate.Types.Filters
+namespace HotChocolate.Types.Filters;
+
+[Obsolete]
+public class MongoFilterTests : IClassFixture
{
- [Obsolete]
- public class MongoFilterTests
- : IClassFixture
- {
- private readonly MongoResource _mongoResource;
+ private readonly MongoResource _mongoResource;
- public MongoFilterTests(MongoResource mongoResource)
- {
- _mongoResource = mongoResource;
- }
+ public MongoFilterTests(MongoResource mongoResource)
+ {
+ _mongoResource = mongoResource;
+ }
- [Fact]
- public async Task GetItems_NoFilter_AllItems_Are_Returned()
- {
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
+ [Fact]
+ public async Task GetItems_NoFilter_AllItems_Are_Returned()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton(_ =>
+ {
+ var database = _mongoResource.CreateDatabase();
+ var collection = database.GetCollection("col");
+ collection.InsertMany(new[]
{
- IMongoDatabase database = _mongoResource.CreateDatabase();
+ new Model { Foo = "abc", Bar = 1, Baz = true },
+ new Model { Foo = "def", Bar = 2, Baz = false },
+ });
+ return collection;
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .Services
+ .BuildServiceProvider();
- IMongoCollection collection = database.GetCollection("col");
- collection.InsertMany(new[]
- {
- new Model { Foo = "abc", Bar = 1, Baz = true },
- new Model { Foo = "def", Bar = 2, Baz = false },
- });
- return collection;
- })
- .AddGraphQL()
- .AddQueryType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery("{ items { foo } }")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
- [Fact]
- public async Task GetItems_EqualsFilter_FirstItems_Is_Returned()
- {
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
- {
- IMongoDatabase database = _mongoResource.CreateDatabase();
+ var request = QueryRequestBuilder.New()
+ .SetQuery("{ items { foo } }")
+ .Create();
- IMongoCollection collection = database.GetCollection("col");
- collection.InsertMany(new[]
- {
- new Model { Foo = "abc", Bar = 1, Baz = true },
- new Model { Foo = "def", Bar = 2, Baz = false },
- });
- return collection;
- })
- .AddGraphQL()
- .AddQueryType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery("{ items(where: { foo: \"abc\" }) { foo } }")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ // act
+ var result = await executor.ExecuteAsync(request);
- [Fact]
- public async Task GetItems_ObjectEqualsFilter_FirstItems_Is_Returned()
- {
- // arrange
- var serviceCollection = new ServiceCollection();
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
+ // assert
+ result.ToJson().MatchSnapshot();
+ }
+
+ [Fact]
+ public async Task GetItems_EqualsFilter_FirstItems_Is_Returned()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton(_ =>
+ {
+ var database = _mongoResource.CreateDatabase();
+ var collection = database.GetCollection("col");
+ collection.InsertMany(new[]
{
- IMongoDatabase database = _mongoResource.CreateDatabase();
+ new Model { Foo = "abc", Bar = 1, Baz = true },
+ new Model { Foo = "def", Bar = 2, Baz = false },
+ });
+ return collection;
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
- IMongoCollection collection = database.GetCollection("col");
- collection.InsertMany(new[]
+ var request = QueryRequestBuilder.New()
+ .SetQuery("{ items(where: { foo: \"abc\" }) { foo } }")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.ToJson().MatchSnapshot();
+ }
+
+ [Fact]
+ public async Task GetItems_ObjectEqualsFilter_FirstItems_Is_Returned()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton(_ =>
+ {
+ var database = _mongoResource.CreateDatabase();
+
+ var collection = database.GetCollection("col");
+ collection.InsertMany(new[]
+ {
+ new Model
{
- new Model
- {
- Nested = null
- },
- new Model
+ Nested = null
+ },
+ new Model
+ {
+ Nested = new Model
{
Nested = new Model
{
- Nested = new Model
- {
- Foo = "abc",
- Bar = 1,
- Baz = true
- }
+ Foo = "abc",
+ Bar = 1,
+ Baz = true
}
- },
- new Model
+ }
+ },
+ new Model
+ {
+ Nested = new Model
{
- Nested = new Model
+ Nested= new Model
{
- Nested= new Model
- {
- Foo = "def",
- Bar = 2,
- Baz = false
- }
+ Foo = "def",
+ Bar = 2,
+ Baz = false
}
- },
- });
- return collection;
- })
- .AddGraphQL()
- .AddQueryType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery(
- "{ items(where: { nested:{ nested: { foo: \"abc\" " +
- "} } }) { nested { nested { foo } } } }")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ }
+ },
+ });
+ return collection;
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .Services
+ .BuildServiceProvider();
+
+ var executor =
+ await services.GetRequiredService()
+ .GetRequestExecutorAsync();
+
+ var request = QueryRequestBuilder.New()
+ .SetQuery(
+ "{ items(where: { nested:{ nested: { foo: \"abc\" " +
+ "} } }) { nested { nested { foo } } } }")
+ .Create();
+
+ // act
+ var result = await executor.ExecuteAsync(request);
+
+ // assert
+ result.ToJson().MatchSnapshot();
+ }
- [Fact]
- public async Task GetItems_With_Paging_EqualsFilter_FirstItems_Is_Returned()
- {
- // arrange
- IServiceProvider services = new ServiceCollection()
- .AddSingleton>(sp =>
+ [Fact]
+ public async Task GetItems_With_Paging_EqualsFilter_FirstItems_Is_Returned()
+ {
+ // arrange
+ IServiceProvider services = new ServiceCollection()
+ .AddSingleton(_ =>
+ {
+ var database = _mongoResource.CreateDatabase();
+
+ var collection = database.GetCollection("col");
+ collection.InsertMany(new[]
{
- IMongoDatabase database = _mongoResource.CreateDatabase();
+ new Model { Foo = "abc", Bar = 1, Baz = true },
+ new Model { Foo = "def", Bar = 2, Baz = false },
+ });
+ return collection;
+ })
+ .AddGraphQL()
+ .AddQueryType()
+ .Services
+ .BuildServiceProvider();
- IMongoCollection collection = database.GetCollection("col");
- collection.InsertMany(new[]
- {
- new Model { Foo = "abc", Bar = 1, Baz = true },
- new Model { Foo = "def", Bar = 2, Baz = false },
- });
- return collection;
- })
- .AddGraphQL()
- .AddQueryType()
- .Services
- .BuildServiceProvider();
-
- IRequestExecutor executor =
- await services.GetRequiredService()
- .GetRequestExecutorAsync();
-
- IReadOnlyQueryRequest request = QueryRequestBuilder.New()
- .SetQuery("{ paging(where: { foo: \"abc\" }) { nodes { foo } } }")
- .Create();
-
- // act
- IExecutionResult result = await executor.ExecuteAsync(request);
-
- // assert
- result.MatchSnapshot();
- }
+ var executor =
+ await services.GetRequiredService