Skip to content

Commit f02d103

Browse files
authored
Enabled the GraphQL HTTP client to work with the new persisted query routes. (#6963)
1 parent 14563c8 commit f02d103

File tree

6 files changed

+29
-65
lines changed

6 files changed

+29
-65
lines changed

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100"
3+
"version": "8.0.100",
4+
"rollForward": "major"
45
}
56
}

src/HotChocolate/AspNetCore/src/Transport.Abstractions/OperationRequest.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ public OperationRequest(
4040
ObjectValueNode? variables,
4141
ObjectValueNode? extensions)
4242
{
43-
if (string.IsNullOrWhiteSpace(query) && id is null && extensions is null)
44-
{
45-
throw new ArgumentException(
46-
OperationRequest_QueryOrPersistedQueryId,
47-
nameof(query));
48-
}
49-
5043
Query = query;
5144
Id = id;
5245
OperationName = operationName;
@@ -82,20 +75,18 @@ public OperationRequest(
8275
IReadOnlyDictionary<string, object?>? variables = null,
8376
IReadOnlyDictionary<string, object?>? extensions = null)
8477
{
85-
if (string.IsNullOrWhiteSpace(query) && id is null && extensions is null)
86-
{
87-
throw new ArgumentException(
88-
OperationRequest_QueryOrPersistedQueryId,
89-
nameof(query));
90-
}
91-
9278
Query = query;
9379
Id = id;
9480
OperationName = operationName;
9581
Variables = variables;
9682
Extensions = extensions;
9783
}
9884

85+
/// <summary>
86+
/// Empty Operation Request.
87+
/// </summary>
88+
public static OperationRequest Empty { get; } = new();
89+
9990
/// <summary>
10091
/// Gets the ID of a previously persisted query that should be executed.
10192
/// </summary>

src/HotChocolate/AspNetCore/src/Transport.Abstractions/Properties/TransportAbstractionResoucrces.Designer.cs

Lines changed: 16 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/HotChocolate/AspNetCore/src/Transport.Abstractions/Properties/TransportAbstractionResoucrces.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
<resheader name="writer">
1919
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
2020
</resheader>
21-
<data name="OperationRequest_QueryOrPersistedQueryId" xml:space="preserve">
22-
<value>Either a query needs to be provided or a persisted query id.</value>
23-
</data>
2421
<data name="OperationResult_Parse_JsonDataIsEmpty" xml:space="preserve">
2522
<value>The JSON document is empty.</value>
2623
</data>

src/HotChocolate/AspNetCore/src/Transport.Abstractions/Serialization/Utf8JsonWriterHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void WriteOperationRequest(Utf8JsonWriter writer, OperationRequest
2121
{
2222
writer.WriteString(Utf8GraphQLRequestProperties.IdProp, request.Id);
2323
}
24-
24+
2525
if (request.Query is not null)
2626
{
2727
writer.WriteString(Utf8GraphQLRequestProperties.QueryProp, request.Query);

src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ operation.Extensions is null &&
8686
/// Specifies if files shall be uploaded using the multipart request spec.
8787
/// </summary>
8888
public bool EnableFileUploads { get; set; }
89+
90+
/// <summary>
91+
/// Specifies that the request URI represents a persisted document URI.
92+
/// </summary>
93+
public bool PersistedDocumentUri { get; set; }
8994

9095
public static implicit operator GraphQLHttpRequest(OperationRequest method) => new(method);
9196
}

0 commit comments

Comments
 (0)