From 8ead768b63624a12c8b324ad038f476f7929e9e2 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 26 Jul 2025 16:40:24 +1000 Subject: [PATCH 1/3] remove disableAsync feature --- docs/configuration.md | 10 ++++------ src/GraphQL.EntityFramework/EfGraphQLConventions.cs | 11 ++++------- .../GraphApi/EfGraphQLService.cs | 5 +---- .../GraphApi/EfGraphQLService_First.cs | 10 +--------- .../GraphApi/EfGraphQLService_NavigationConnection.cs | 2 -- .../GraphApi/EfGraphQLService_Queryable.cs | 8 -------- .../GraphApi/EfGraphQLService_QueryableConnection.cs | 3 --- .../GraphApi/EfGraphQLService_Single.cs | 10 +--------- src/Tests/IntegrationTests/IntegrationTests.cs | 3 +-- src/Tests/IntegrationTests/QueryExecutor.cs | 6 ++---- 10 files changed, 14 insertions(+), 54 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index e6f15340..98225a33 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -22,10 +22,9 @@ public static void RegisterInContainer( ResolveDbContext? resolveDbContext = null, IModel? model = null, ResolveFilters? resolveFilters = null, - bool disableTracking = false, - bool disableAsync = false) + bool disableTracking = false) ``` -snippet source | anchor +snippet source | anchor ```cs EfGraphQLConventions.RegisterInContainer( @@ -123,10 +122,9 @@ public static void RegisterInContainer( ResolveDbContext? resolveDbContext = null, IModel? model = null, ResolveFilters? resolveFilters = null, - bool disableTracking = false, - bool disableAsync = false) + bool disableTracking = false) ``` -snippet source | anchor +snippet source | anchor ```cs EfGraphQLConventions.RegisterInContainer( diff --git a/src/GraphQL.EntityFramework/EfGraphQLConventions.cs b/src/GraphQL.EntityFramework/EfGraphQLConventions.cs index 7f609607..345ab93d 100644 --- a/src/GraphQL.EntityFramework/EfGraphQLConventions.cs +++ b/src/GraphQL.EntityFramework/EfGraphQLConventions.cs @@ -18,8 +18,7 @@ public static void RegisterInContainer( ResolveDbContext? resolveDbContext = null, IModel? model = null, ResolveFilters? resolveFilters = null, - bool disableTracking = false, - bool disableAsync = false) + bool disableTracking = false) #endregion @@ -28,7 +27,7 @@ public static void RegisterInContainer( RegisterScalarsAndArgs(services); services.AddHttpContextAccessor(); services.AddTransient(); - services.AddSingleton(provider => Build(resolveDbContext, model, resolveFilters, provider, disableTracking, disableAsync)); + services.AddSingleton(provider => Build(resolveDbContext, model, resolveFilters, provider, disableTracking)); services.AddSingleton>(provider => provider.GetRequiredService>()); } @@ -37,8 +36,7 @@ static EfGraphQLService Build( IModel? model, ResolveFilters? filters, IServiceProvider provider, - bool disableTracking, - bool disableAsync) + bool disableTracking) where TDbContext : DbContext { model ??= ResolveModel(provider); @@ -49,8 +47,7 @@ static EfGraphQLService Build( model, dbContextResolver, filters, - disableTracking, - disableAsync); + disableTracking); } static TDbContext DbContextFromProvider(IServiceProvider provider, IServiceProvider? requestServices) diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService.cs index 60e8bae4..1b3dc161 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService.cs @@ -6,7 +6,6 @@ public partial class EfGraphQLService : { ResolveFilters? resolveFilters; bool disableTracking; - bool disableAsync; ResolveDbContext resolveDbContext; IReadOnlyDictionary> keyNames; @@ -15,12 +14,10 @@ public EfGraphQLService( IModel model, ResolveDbContext resolveDbContext, ResolveFilters? resolveFilters = null, - bool disableTracking = false, - bool disableAsync = false) + bool disableTracking = false) { this.resolveFilters = resolveFilters; this.disableTracking = disableTracking; - this.disableAsync = disableAsync; this.resolveDbContext = resolveDbContext; keyNames = model.GetKeyNames(); diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_First.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_First.cs index 40f580ed..0b2ccf66 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_First.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_First.cs @@ -159,14 +159,7 @@ FieldType BuildFirstField( TReturn? first; try { - if (disableAsync) - { - first = query.FirstOrDefault(); - } - else - { - first = await query.FirstOrDefaultAsync(context.CancellationToken); - } + first = await query.FirstOrDefaultAsync(context.CancellationToken); } catch (TaskCanceledException) { @@ -184,7 +177,6 @@ FieldType BuildFirstField( GraphType: {graphType.FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} OmitQueryArguments: {omitQueryArguments} Nullable: {nullable} KeyNames: {JoinKeys(names)} diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_NavigationConnection.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_NavigationConnection.cs index 135ef051..54d552ad 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_NavigationConnection.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_NavigationConnection.cs @@ -41,7 +41,6 @@ public ConnectionBuilder AddNavigationConnectionField ItemGraphType: {itemGraphType.FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} """, exception); } @@ -88,7 +87,6 @@ ConnectionBuilder AddEnumerableConnection( TGraph: {typeof(TGraph).FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} """, exception); } diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Queryable.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Queryable.cs index b67ded24..b56c7d80 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Queryable.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Queryable.cs @@ -109,15 +109,8 @@ FieldType BuildQueryField( try { - if (disableAsync) - { - list = query.ToList(); - } - else - { list = await query .ToListAsync(context.CancellationToken); - } } catch (TaskCanceledException) { @@ -137,7 +130,6 @@ FieldType BuildQueryField( TReturn: {typeof(TReturn).FullName} DisableTracking: {disableTracking} HasId: {hasId} - DisableAsync: {disableAsync} KeyNames: {JoinKeys(names)} Query: {query.ToQueryString()} """, diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_QueryableConnection.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_QueryableConnection.cs index c4ba3e4a..973b139e 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_QueryableConnection.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_QueryableConnection.cs @@ -56,7 +56,6 @@ public ConnectionBuilder AddQueryConnectionField( Failed to execute query for field `{name}` ItemGraphType: {itemGraphType.FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} """, exception); } @@ -114,7 +113,6 @@ public ConnectionBuilder AddQueryConnectionField( ItemGraphType: {itemGraphType.FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} """, exception); } @@ -175,7 +173,6 @@ ConnectionBuilder AddQueryableConnection( TGraph: {typeof(TGraph).FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} KeyNames: {JoinKeys(names)} Query: {query.ToQueryString()} """, diff --git a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Single.cs b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Single.cs index 50b894d6..4d3b1c9d 100644 --- a/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Single.cs +++ b/src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Single.cs @@ -160,14 +160,7 @@ FieldType BuildSingleField( TReturn? single; try { - if (disableAsync) - { - single = query.SingleOrDefault(); - } - else - { - single = await query.SingleOrDefaultAsync(context.CancellationToken); - } + single = await query.SingleOrDefaultAsync(context.CancellationToken); } catch (TaskCanceledException) { @@ -185,7 +178,6 @@ FieldType BuildSingleField( GraphType: {graphType.FullName} TSource: {typeof(TSource).FullName} TReturn: {typeof(TReturn).FullName} - DisableAsync: {disableAsync} OmitQueryArguments: {omitQueryArguments} Nullable: {nullable} KeyNames: {JoinKeys(names)} diff --git a/src/Tests/IntegrationTests/IntegrationTests.cs b/src/Tests/IntegrationTests/IntegrationTests.cs index 0c714451..42cdcae9 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.cs +++ b/src/Tests/IntegrationTests/IntegrationTests.cs @@ -3078,7 +3078,6 @@ static async Task RunQuery( Filters? filters, bool disableTracking, object[] entities, - bool disableAsync = false, [CallerFilePath] string sourceFile = "") { var dbContext = database.Context; @@ -3099,7 +3098,7 @@ static async Task RunQuery( string result; try { - result = await QueryExecutor.ExecuteQuery(query, services, context, inputs, filters, disableTracking, disableAsync); + result = await QueryExecutor.ExecuteQuery(query, services, context, inputs, filters, disableTracking); } catch (ExecutionError executionError) { diff --git a/src/Tests/IntegrationTests/QueryExecutor.cs b/src/Tests/IntegrationTests/QueryExecutor.cs index b79244ca..5ee7227b 100644 --- a/src/Tests/IntegrationTests/QueryExecutor.cs +++ b/src/Tests/IntegrationTests/QueryExecutor.cs @@ -6,8 +6,7 @@ public static async Task ExecuteQuery( TDbContext data, Inputs? inputs, Filters? filters, - bool disableTracking, - bool disableAsync) + bool disableTracking) where TDbContext : DbContext { EfGraphQLConventions.RegisterInContainer( @@ -15,8 +14,7 @@ public static async Task ExecuteQuery( (_, _) => data, data.Model, _ => filters, - disableTracking, - disableAsync); + disableTracking); await using var provider = services.BuildServiceProvider(); using var schema = new Schema(provider); var executer = new EfDocumentExecuter(); From 7796f57027ff616f9a631ee2594d56161699d51a Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 26 Jul 2025 16:42:25 +1000 Subject: [PATCH 2/3] Update Directory.Build.props --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cfa3b3fa..3a15c8b5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CS1591;NU5104;CS1573;CS9107;NU1608;NU1109 - 31.0.5 + 32.0.0 preview 1.0.0 EntityFrameworkCore, EntityFramework, GraphQL From 7d69e40f46b63087683ac837d2cd4c8b23eb183c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 26 Jul 2025 16:47:42 +1000 Subject: [PATCH 3/3] . --- ...irst_Found_Large_Text_NoAsync.verified.txt | 17 --- ...ests.Query_Large_Text_NoAsync.verified.txt | 38 ------- ...ngle_Found_Large_Text_NoAsync.verified.txt | 17 --- .../IntegrationTests/IntegrationTests.cs | 101 ------------------ 4 files changed, 173 deletions(-) delete mode 100644 src/Tests/IntegrationTests/IntegrationTests.First_Found_Large_Text_NoAsync.verified.txt delete mode 100644 src/Tests/IntegrationTests/IntegrationTests.Query_Large_Text_NoAsync.verified.txt delete mode 100644 src/Tests/IntegrationTests/IntegrationTests.Single_Found_Large_Text_NoAsync.verified.txt diff --git a/src/Tests/IntegrationTests/IntegrationTests.First_Found_Large_Text_NoAsync.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.First_Found_Large_Text_NoAsync.verified.txt deleted file mode 100644 index 43eb78b6..00000000 --- a/src/Tests/IntegrationTests/IntegrationTests.First_Found_Large_Text_NoAsync.verified.txt +++ /dev/null @@ -1,17 +0,0 @@ -{ - target: -{ - "data": { - "parentEntityFirst": { - "id": "Guid_1" - } - } -}, - sql: { - Text: -select top (1) p.Id, - p.Property -from ParentEntities as p -where p.Id = 'Guid_1' - } -} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/IntegrationTests.Query_Large_Text_NoAsync.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Query_Large_Text_NoAsync.verified.txt deleted file mode 100644 index ef4e517f..00000000 --- a/src/Tests/IntegrationTests/IntegrationTests.Query_Large_Text_NoAsync.verified.txt +++ /dev/null @@ -1,38 +0,0 @@ -{ - target: -{ - "data": { - "childEntities": [ - { - "parent": { - "property": "Value1" - } - }, - { - "parent": { - "property": "Value1" - } - }, - { - "parent": { - "property": "Value4" - } - } - ] - } -}, - sql: { - Text: -select c.Id, - c.Nullable, - c.ParentId, - c.Property, - p.Id, - p.Property -from ChildEntities as c - left outer join - ParentEntities as p - on c.ParentId = p.Id -order by c.Property - } -} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/IntegrationTests.Single_Found_Large_Text_NoAsync.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Single_Found_Large_Text_NoAsync.verified.txt deleted file mode 100644 index 1290d721..00000000 --- a/src/Tests/IntegrationTests/IntegrationTests.Single_Found_Large_Text_NoAsync.verified.txt +++ /dev/null @@ -1,17 +0,0 @@ -{ - target: -{ - "data": { - "parentEntity": { - "id": "Guid_1" - } - } -}, - sql: { - Text: -select top (2) p.Id, - p.Property -from ParentEntities as p -where p.Id = 'Guid_1' - } -} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/IntegrationTests.cs b/src/Tests/IntegrationTests/IntegrationTests.cs index 42cdcae9..2708c531 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.cs +++ b/src/Tests/IntegrationTests/IntegrationTests.cs @@ -1105,60 +1105,6 @@ public async Task First_Found_NoTracking() await RunQuery(database, query, null, null, true, [entity1, entity2]); } - [Fact] - public async Task Single_Found_Large_Text_NoAsync() - { - var query = - """ - { - parentEntity(id: "00000000-0000-0000-0000-000000000001") { - id - } - } - """; - var largeString = new StringBuilder().Append('a', 3 * 1024 * 1024); - var entity1 = new ParentEntity - { - Id = new("00000000-0000-0000-0000-000000000001"), - Property = largeString.ToString() - }; - var entity2 = new ParentEntity - { - Id = new("00000000-0000-0000-0000-000000000002"), - Property = "Value2" - }; - - await using var database = await sqlInstance.Build(); - await RunQuery(database, query, null, null, false, [entity1, entity2], true); - } - - [Fact] - public async Task First_Found_Large_Text_NoAsync() - { - var query = - """ - { - parentEntityFirst(id: "00000000-0000-0000-0000-000000000001") { - id - } - } - """; - var largeString = new StringBuilder().Append('a', 3 * 1024 * 1024); - var entity1 = new ParentEntity - { - Id = new("00000000-0000-0000-0000-000000000001"), - Property = largeString.ToString() - }; - var entity2 = new ParentEntity - { - Id = new("00000000-0000-0000-0000-000000000002"), - Property = "Value2" - }; - - await using var database = await sqlInstance.Build(); - await RunQuery(database, query, null, null, false, [entity1, entity2], true); - } - [Fact] public async Task Owned() { @@ -2362,53 +2308,6 @@ public async Task Query_NoTracking() await RunQuery(database, query, null, null, true, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] - public async Task Query_Large_Text_NoAsync() - { - var query = - """ - { - childEntities (orderBy: {path: "property"}) - { - parent - { - property - } - } - } - """; - var largeString = new StringBuilder().Append('a', 3 * 1024 * 1024); - var entity1 = new ParentEntity - { - Property = "Value1" - }; - var entity2 = new ChildEntity - { - Property = largeString.ToString(), - Parent = entity1 - }; - var entity3 = new ChildEntity - { - Property = "Value3", - Parent = entity1 - }; - entity1.Children.Add(entity2); - entity1.Children.Add(entity3); - var entity4 = new ParentEntity - { - Property = "Value4" - }; - var entity5 = new ChildEntity - { - Property = "Value5", - Parent = entity4 - }; - entity4.Children.Add(entity5); - - await using var database = await sqlInstance.Build(); - await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5], true); - } - [Fact] public async Task Child_parent() {