-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add stringsyntaxattribute to constructor of GraphQLHttpRequest, ad "QL" abbreviation to resharper dictionary * disable compiler warnings in stub StringSyntaxAttribute for netstandard2.0 * upgrade dependencies * use dotnet 8.0 for gh workflows
- Loading branch information
Showing
17 changed files
with
96 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QL/@EntryIndexedValue">QL</s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,53 @@ | ||
#pragma warning disable IDE0005 | ||
// see https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/implicit-global-using-netfx | ||
using System.Net.Http; | ||
#pragma warning restore IDE0005 | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using GraphQL.Client.Abstractions; | ||
|
||
namespace GraphQL.Client.Http; | ||
|
||
public class GraphQLHttpRequest : GraphQLRequest | ||
{ | ||
public GraphQLHttpRequest() | ||
{ | ||
} | ||
|
||
public GraphQLHttpRequest(string query, object? variables = null, string? operationName = null, Dictionary<string, object?>? extensions = null) | ||
: base(query, variables, operationName, extensions) | ||
{ | ||
} | ||
|
||
public GraphQLHttpRequest(GraphQLRequest other) | ||
: base(other) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a <see cref="HttpRequestMessage"/> from this <see cref="GraphQLHttpRequest"/>. | ||
/// Used by <see cref="GraphQLHttpClient"/> to convert GraphQL requests when sending them as regular HTTP requests. | ||
/// </summary> | ||
/// <param name="options">the <see cref="GraphQLHttpClientOptions"/> passed from <see cref="GraphQLHttpClient"/></param> | ||
/// <param name="serializer">the <see cref="IGraphQLJsonSerializer"/> passed from <see cref="GraphQLHttpClient"/></param> | ||
/// <returns></returns> | ||
public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions options, IGraphQLJsonSerializer serializer) | ||
{ | ||
var message = new HttpRequestMessage(HttpMethod.Post, options.EndPoint) | ||
{ | ||
Content = new StringContent(serializer.SerializeToString(this), Encoding.UTF8, options.MediaType) | ||
}; | ||
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/graphql-response+json")); | ||
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
#pragma warning disable IDE0005 | ||
// see https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/implicit-global-using-netfx | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Net.Http; | ||
#pragma warning restore IDE0005 | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using GraphQL.Client.Abstractions; | ||
|
||
namespace GraphQL.Client.Http; | ||
|
||
public class GraphQLHttpRequest : GraphQLRequest | ||
{ | ||
public GraphQLHttpRequest() | ||
{ | ||
} | ||
|
||
public GraphQLHttpRequest([StringSyntax("GraphQL")] string query, object? variables = null, string? operationName = null, Dictionary<string, object?>? extensions = null) | ||
: base(query, variables, operationName, extensions) | ||
{ | ||
} | ||
|
||
public GraphQLHttpRequest(GraphQLRequest other) | ||
: base(other) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a <see cref="HttpRequestMessage"/> from this <see cref="GraphQLHttpRequest"/>. | ||
/// Used by <see cref="GraphQLHttpClient"/> to convert GraphQL requests when sending them as regular HTTP requests. | ||
/// </summary> | ||
/// <param name="options">the <see cref="GraphQLHttpClientOptions"/> passed from <see cref="GraphQLHttpClient"/></param> | ||
/// <param name="serializer">the <see cref="IGraphQLJsonSerializer"/> passed from <see cref="GraphQLHttpClient"/></param> | ||
/// <returns></returns> | ||
public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions options, IGraphQLJsonSerializer serializer) | ||
{ | ||
var message = new HttpRequestMessage(HttpMethod.Post, options.EndPoint) | ||
{ | ||
Content = new StringContent(serializer.SerializeToString(this), Encoding.UTF8, options.MediaType) | ||
}; | ||
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/graphql-response+json")); | ||
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
message.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8")); | ||
|
||
// Explicitly setting content header to avoid issues with some GrahQL servers | ||
message.Content.Headers.ContentType = new MediaTypeHeaderValue(options.MediaType); | ||
|
||
if (options.DefaultUserAgentRequestHeader != null) | ||
message.Headers.UserAgent.Add(options.DefaultUserAgentRequestHeader); | ||
|
||
return message; | ||
} | ||
} | ||
message.Content.Headers.ContentType = new MediaTypeHeaderValue(options.MediaType); | ||
|
||
if (options.DefaultUserAgentRequestHeader != null) | ||
message.Headers.UserAgent.Add(options.DefaultUserAgentRequestHeader); | ||
|
||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
#if !NET7_0_OR_GREATER | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Stub | ||
/// </summary> | ||
public sealed class StringSyntaxAttribute : Attribute | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
#pragma warning disable IDE1006 | ||
public const string CompositeFormat = nameof(CompositeFormat); | ||
#pragma warning restore IDE1006 | ||
|
||
#pragma warning disable IDE0060 | ||
public StringSyntaxAttribute(string syntax) | ||
{ | ||
} | ||
|
||
{ } | ||
#pragma warning restore IDE0060 | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters