Skip to content

Commit 5946a76

Browse files
committed
sql preview
1 parent da9aea9 commit 5946a76

10 files changed

+16
-55
lines changed

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageVersion Include="MarkdownSnippets.MsBuild" Version="27.0.2" />
1515
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
1616
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.4" />
17-
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.2" />
17+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.0-preview1.25120.4" />
1818
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
1919
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.4" />
2020
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />

src/GraphQL.EntityFramework/EfGraphQLConventions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public static void RegisterInContainer<TDbContext>(
1818
ResolveDbContext<TDbContext>? resolveDbContext = null,
1919
IModel? model = null,
2020
ResolveFilters<TDbContext>? resolveFilters = null,
21-
bool disableTracking = false,
22-
bool disableAsync = false)
21+
bool disableTracking = false)
2322

2423
#endregion
2524

@@ -28,7 +27,7 @@ public static void RegisterInContainer<TDbContext>(
2827
RegisterScalarsAndArgs(services);
2928
services.AddHttpContextAccessor();
3029
services.AddTransient<HttpContextCapture>();
31-
services.AddSingleton(provider => Build(resolveDbContext, model, resolveFilters, provider, disableTracking, disableAsync));
30+
services.AddSingleton(provider => Build(resolveDbContext, model, resolveFilters, provider, disableTracking));
3231
services.AddSingleton<IEfGraphQLService<TDbContext>>(provider => provider.GetRequiredService<EfGraphQLService<TDbContext>>());
3332
}
3433

@@ -37,8 +36,7 @@ static EfGraphQLService<TDbContext> Build<TDbContext>(
3736
IModel? model,
3837
ResolveFilters<TDbContext>? filters,
3938
IServiceProvider provider,
40-
bool disableTracking,
41-
bool disableAsync)
39+
bool disableTracking)
4240
where TDbContext : DbContext
4341
{
4442
model ??= ResolveModel<TDbContext>(provider);
@@ -49,8 +47,7 @@ static EfGraphQLService<TDbContext> Build<TDbContext>(
4947
model,
5048
dbContextResolver,
5149
filters,
52-
disableTracking,
53-
disableAsync);
50+
disableTracking);
5451
}
5552

5653
static TDbContext DbContextFromProvider<TDbContext>(IServiceProvider provider, IServiceProvider? requestServices)

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public partial class EfGraphQLService<TDbContext> :
66
{
77
ResolveFilters<TDbContext>? resolveFilters;
88
bool disableTracking;
9-
bool disableAsync;
109
ResolveDbContext<TDbContext> resolveDbContext;
1110
IReadOnlyDictionary<Type, List<string>> keyNames;
1211

@@ -15,12 +14,10 @@ public EfGraphQLService(
1514
IModel model,
1615
ResolveDbContext<TDbContext> resolveDbContext,
1716
ResolveFilters<TDbContext>? resolveFilters = null,
18-
bool disableTracking = false,
19-
bool disableAsync = false)
17+
bool disableTracking = false)
2018
{
2119
this.resolveFilters = resolveFilters;
2220
this.disableTracking = disableTracking;
23-
this.disableAsync = disableAsync;
2421
this.resolveDbContext = resolveDbContext;
2522

2623
keyNames = model.GetKeyNames();

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_First.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,7 @@ FieldType BuildFirstField<TSource, TReturn>(
159159
TReturn? first;
160160
try
161161
{
162-
if (disableAsync)
163-
{
164-
first = query.FirstOrDefault();
165-
}
166-
else
167-
{
168-
first = await query.FirstOrDefaultAsync(context.CancellationToken);
169-
}
162+
first = await query.FirstOrDefaultAsync(context.CancellationToken);
170163
}
171164
catch (TaskCanceledException)
172165
{
@@ -184,7 +177,6 @@ FieldType BuildFirstField<TSource, TReturn>(
184177
GraphType: {graphType.FullName}
185178
TSource: {typeof(TSource).FullName}
186179
TReturn: {typeof(TReturn).FullName}
187-
DisableAsync: {disableAsync}
188180
OmitQueryArguments: {omitQueryArguments}
189181
Nullable: {nullable}
190182
KeyNames: {JoinKeys(names)}

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_NavigationConnection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public ConnectionBuilder<TSource> AddNavigationConnectionField<TSource, TReturn>
4141
ItemGraphType: {itemGraphType.FullName}
4242
TSource: {typeof(TSource).FullName}
4343
TReturn: {typeof(TReturn).FullName}
44-
DisableAsync: {disableAsync}
4544
""",
4645
exception);
4746
}
@@ -88,7 +87,6 @@ ConnectionBuilder<TSource> AddEnumerableConnection<TSource, TGraph, TReturn>(
8887
TGraph: {typeof(TGraph).FullName}
8988
TSource: {typeof(TSource).FullName}
9089
TReturn: {typeof(TReturn).FullName}
91-
DisableAsync: {disableAsync}
9290
""",
9391
exception);
9492
}

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Queryable.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,8 @@ FieldType BuildQueryField<TSource, TReturn>(
109109

110110
try
111111
{
112-
if (disableAsync)
113-
{
114-
list = query.ToList();
115-
}
116-
else
117-
{
118-
list = await query
119-
.ToListAsync(context.CancellationToken);
120-
}
112+
list = await query
113+
.ToListAsync(context.CancellationToken);
121114
}
122115
catch (TaskCanceledException)
123116
{
@@ -137,7 +130,6 @@ FieldType BuildQueryField<TSource, TReturn>(
137130
TReturn: {typeof(TReturn).FullName}
138131
DisableTracking: {disableTracking}
139132
HasId: {hasId}
140-
DisableAsync: {disableAsync}
141133
KeyNames: {JoinKeys(names)}
142134
Query: {query.ToQueryString()}
143135
""",

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_QueryableConnection.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public ConnectionBuilder<object> AddQueryConnectionField<TReturn>(
5656
Failed to execute query for field `{name}`
5757
ItemGraphType: {itemGraphType.FullName}
5858
TReturn: {typeof(TReturn).FullName}
59-
DisableAsync: {disableAsync}
6059
""",
6160
exception);
6261
}
@@ -114,7 +113,6 @@ public ConnectionBuilder<TSource> AddQueryConnectionField<TSource, TReturn>(
114113
ItemGraphType: {itemGraphType.FullName}
115114
TSource: {typeof(TSource).FullName}
116115
TReturn: {typeof(TReturn).FullName}
117-
DisableAsync: {disableAsync}
118116
""",
119117
exception);
120118
}
@@ -175,7 +173,6 @@ ConnectionBuilder<TSource> AddQueryableConnection<TSource, TGraph, TReturn>(
175173
TGraph: {typeof(TGraph).FullName}
176174
TSource: {typeof(TSource).FullName}
177175
TReturn: {typeof(TReturn).FullName}
178-
DisableAsync: {disableAsync}
179176
KeyNames: {JoinKeys(names)}
180177
Query: {query.ToQueryString()}
181178
""",

src/GraphQL.EntityFramework/GraphApi/EfGraphQLService_Single.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,7 @@ FieldType BuildSingleField<TSource, TReturn>(
160160
TReturn? single;
161161
try
162162
{
163-
if (disableAsync)
164-
{
165-
single = query.SingleOrDefault();
166-
}
167-
else
168-
{
169-
single = await query.SingleOrDefaultAsync(context.CancellationToken);
170-
}
163+
single = await query.SingleOrDefaultAsync(context.CancellationToken);
171164
}
172165
catch (TaskCanceledException)
173166
{
@@ -185,7 +178,6 @@ FieldType BuildSingleField<TSource, TReturn>(
185178
GraphType: {graphType.FullName}
186179
TSource: {typeof(TSource).FullName}
187180
TReturn: {typeof(TReturn).FullName}
188-
DisableAsync: {disableAsync}
189181
OmitQueryArguments: {omitQueryArguments}
190182
Nullable: {nullable}
191183
KeyNames: {JoinKeys(names)}

src/Tests/IntegrationTests/IntegrationTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ public async Task Connection_page_back()
692692

693693
await using var database = await sqlInstance.Build();
694694
await RunQuery(database, query, null, null, false, entities.ToArray());
695-
696695
}
697696

698697
[Fact]
@@ -1129,7 +1128,7 @@ public async Task Single_Found_Large_Text_NoAsync()
11291128
};
11301129

11311130
await using var database = await sqlInstance.Build();
1132-
await RunQuery(database, query, null, null, false, [entity1, entity2], true);
1131+
await RunQuery(database, query, null, null, false, [entity1, entity2]);
11331132
}
11341133

11351134
[Fact]
@@ -1156,7 +1155,7 @@ public async Task First_Found_Large_Text_NoAsync()
11561155
};
11571156

11581157
await using var database = await sqlInstance.Build();
1159-
await RunQuery(database, query, null, null, false, [entity1, entity2], true);
1158+
await RunQuery(database, query, null, null, false, [entity1, entity2]);
11601159
}
11611160

11621161
[Fact]
@@ -2406,7 +2405,7 @@ public async Task Query_Large_Text_NoAsync()
24062405
entity4.Children.Add(entity5);
24072406

24082407
await using var database = await sqlInstance.Build();
2409-
await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5], true);
2408+
await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]);
24102409
}
24112410

24122411
[Fact]
@@ -3078,7 +3077,6 @@ static async Task RunQuery(
30783077
Filters<IntegrationDbContext>? filters,
30793078
bool disableTracking,
30803079
object[] entities,
3081-
bool disableAsync = false,
30823080
[CallerFilePath] string sourceFile = "")
30833081
{
30843082
var dbContext = database.Context;
@@ -3099,7 +3097,7 @@ static async Task RunQuery(
30993097
string result;
31003098
try
31013099
{
3102-
result = await QueryExecutor.ExecuteQuery(query, services, context, inputs, filters, disableTracking, disableAsync);
3100+
result = await QueryExecutor.ExecuteQuery(query, services, context, inputs, filters, disableTracking);
31033101
}
31043102
catch (ExecutionError executionError)
31053103
{

src/Tests/IntegrationTests/QueryExecutor.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ public static async Task<string> ExecuteQuery<TDbContext>(
66
TDbContext data,
77
Inputs? inputs,
88
Filters<TDbContext>? filters,
9-
bool disableTracking,
10-
bool disableAsync)
9+
bool disableTracking)
1110
where TDbContext : DbContext
1211
{
1312
EfGraphQLConventions.RegisterInContainer(
1413
services,
1514
(_, _) => data,
1615
data.Model,
1716
_ => filters,
18-
disableTracking,
19-
disableAsync);
17+
disableTracking);
2018
await using var provider = services.BuildServiceProvider();
2119
using var schema = new Schema(provider);
2220
var executer = new EfDocumentExecuter();

0 commit comments

Comments
 (0)