Skip to content

Commit 0ceeb66

Browse files
authored
Added more route variants to persisted query middleware. (#6954)
1 parent 157e17e commit 0ceeb66

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/HotChocolate/AspNetCore/src/AspNetCore/PersistedQueryMiddleware.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ internal static class PersistedQueryMiddleware
1313
internal static void MapPersistedQueryMiddleware(this RouteGroupBuilder groupBuilder, string schemaName)
1414
{
1515
var state = new State(schemaName);
16-
16+
17+
groupBuilder
18+
.MapGet(
19+
"/{OperationId}",
20+
([AsParameters] Services services, string operationId)
21+
=> ExecuteGetRequestAsync(state, services, operationId, null));
22+
1723
groupBuilder
1824
.MapGet(
1925
"/{OperationId}/{DisplayName}",
2026
([AsParameters] Services services, string operationId, string displayName)
2127
=> ExecuteGetRequestAsync(state, services, operationId, displayName));
2228

29+
groupBuilder
30+
.MapPost(
31+
"/{OperationId}",
32+
([AsParameters] Services services, string operationId)
33+
=> ExecutePostRequestAsync(state, services, operationId, null));
34+
2335
groupBuilder
2436
.MapPost(
2537
"/{OperationId}/{DisplayName}",
@@ -32,7 +44,7 @@ private static async Task ExecuteGetRequestAsync(
3244
Services services,
3345
string operationId,
3446
// ReSharper disable once UnusedParameter.Local
35-
string displayName)
47+
string? displayName)
3648
{
3749
HttpStatusCode? statusCode;
3850
IExecutionResult? result;
@@ -108,7 +120,7 @@ private static async Task ExecutePostRequestAsync(
108120
Services services,
109121
string operationId,
110122
// ReSharper disable once UnusedParameter.Local
111-
string displayName)
123+
string? displayName)
112124
{
113125
HttpStatusCode? statusCode;
114126
IExecutionResult? result;

0 commit comments

Comments
 (0)