Skip to content

Commit

Permalink
Address #630 (#631)
Browse files Browse the repository at this point in the history
* Address #630

* Multi-framework build for primitives project

* PR feedback: extension methods
  • Loading branch information
lol768 authored Apr 16, 2024
1 parent 3e06275 commit 875520a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Abstractions for GraphQL.Client</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/GraphQL.Client.Abstractions/GraphQLClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics.CodeAnalysis;

namespace GraphQL.Client.Abstractions;

public static class GraphQLClientExtensions
{
public static Task<GraphQLResponse<TResponse>> SendQueryAsync<TResponse>(this IGraphQLClient client,
string query, object? variables = null,
[StringSyntax("GraphQL")] string query, object? variables = null,
string? operationName = null, Func<TResponse> defineResponseType = null, CancellationToken cancellationToken = default)
{
_ = defineResponseType;
Expand All @@ -12,7 +14,7 @@ public static Task<GraphQLResponse<TResponse>> SendQueryAsync<TResponse>(this IG
}

public static Task<GraphQLResponse<TResponse>> SendMutationAsync<TResponse>(this IGraphQLClient client,
string query, object? variables = null,
[StringSyntax("GraphQL")] string query, object? variables = null,
string? operationName = null, Func<TResponse> defineResponseType = null, CancellationToken cancellationToken = default)
{
_ = defineResponseType;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Primitives/GraphQL.Primitives.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>GraphQL basic types</Description>
<RootNamespace>GraphQL</RootNamespace>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

</Project>
5 changes: 4 additions & 1 deletion src/GraphQL.Primitives/GraphQLRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Diagnostics.CodeAnalysis;

namespace GraphQL;

/// <summary>
Expand All @@ -13,6 +15,7 @@ public class GraphQLRequest : Dictionary<string, object>, IEquatable<GraphQLRequ
/// <summary>
/// The Query
/// </summary>
[StringSyntax("GraphQL")]
public string Query
{
get => TryGetValue(QUERY_KEY, out object value) ? (string)value : null;
Expand Down Expand Up @@ -48,7 +51,7 @@ public object? Variables

public GraphQLRequest() { }

public GraphQLRequest(string query, object? variables = null, string? operationName = null, Dictionary<string, object?>? extensions = null)
public GraphQLRequest([StringSyntax("GraphQL")] string query, object? variables = null, string? operationName = null, Dictionary<string, object?>? extensions = null)
{
Query = query;
Variables = variables;
Expand Down
17 changes: 17 additions & 0 deletions src/GraphQL.Primitives/StringSyntaxAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#if !NET7_0_OR_GREATER

namespace System.Diagnostics.CodeAnalysis;

/// <summary>
/// Stub
/// </summary>
public sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = nameof(CompositeFormat);

public StringSyntaxAttribute(string syntax)
{
}

}
#endif

0 comments on commit 875520a

Please sign in to comment.