Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion root.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<NoWarn></NoWarn>
<NoWarn>CS1591</NoWarn>
<PackageIconUrl>https://raw.githubusercontent.com/graphql-dotnet/graphql-client/master/assets/logo.64x64.png</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/graphql-dotnet/graphql-client/master/LICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/graphql-dotnet/graphql-client</PackageProjectUrl>
Expand Down
24 changes: 12 additions & 12 deletions src/GraphQL.Client/GraphQL.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../src.props" />
<Import Project="../src.props" />

<PropertyGroup>
<Description>A GraphQL Client</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Description>A GraphQL Client</Description>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GraphQL.Common\GraphQL.Common.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GraphQL.Common\GraphQL.Common.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.1'">
<PackageReference Include="System.Net.Http" Version="4.3.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2" />
</ItemGroup>

<!-- Allow method ReadAsAsync<T>
<!-- Allow method ReadAsAsync<T>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.4" />
</ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/GraphQL.Client/GraphQLClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ public async Task<GraphQLResponse> PostAsync(GraphQLRequest request, Cancellatio
}
}

[Obsolete("EXPERIMENTAL API")]
public async Task<GraphQLSubscriptionResult> SubscribeAsync(string query, CancellationToken cancellationToken = default) {
if (query == null) { throw new ArgumentNullException(nameof(query)); }

return await this.SubscribeAsync(new GraphQLRequest { Query=query},cancellationToken).ConfigureAwait(false);
}

[Obsolete("EXPERIMENTAL API")]
public async Task<GraphQLSubscriptionResult> SubscribeAsync(GraphQLRequest request,CancellationToken cancellationToken = default) {
var a= new GraphQLSubscriptionResult();
return await Task.FromResult(a);
}

/// <summary>
/// Releases unmanaged resources
/// </summary>
Expand Down
19 changes: 12 additions & 7 deletions src/GraphQL.Client/GraphQLClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading;
using System.Threading.Tasks;
using GraphQL.Common.Request;
using GraphQL.Common.Response;
Expand All @@ -9,8 +10,7 @@ namespace GraphQL.Client {
/// </summary>
public static class GraphQLClientExtensions {

private static readonly GraphQLRequest IntrospectionQuery = new GraphQLRequest {
Query = @"
private const string IntrospectionQuery = @"
query IntrospectionQuery {
__schema {
queryType {
Expand Down Expand Up @@ -95,25 +95,30 @@ fragment TypeRef on __Type {
}
}
}
}".Replace("\t", "").Replace("\n", "").Replace("\r", ""),
}";

private static readonly GraphQLRequest IntrospectionGraphQLRequest = new GraphQLRequest {
Query = IntrospectionQuery.Replace("\t", "").Replace("\n", "").Replace("\r", ""),
Variables = null
};

/// <summary>
/// Send an IntrospectionQuery via GET
/// </summary>
/// <param name="graphQLClient">The GraphQLClient</param>
/// <param name="cancellationToken"></param>
/// <returns>The GraphQLResponse</returns>
public static async Task<GraphQLResponse> GetIntrospectionQueryAsync(this GraphQLClient graphQLClient) =>
await graphQLClient.GetAsync(IntrospectionQuery).ConfigureAwait(false);
public static async Task<GraphQLResponse> GetIntrospectionQueryAsync(this GraphQLClient graphQLClient, CancellationToken cancellationToken = default) =>
await graphQLClient.GetAsync(IntrospectionGraphQLRequest, cancellationToken).ConfigureAwait(false);

/// <summary>
/// Send an IntrospectionQuery via POST
/// </summary>
/// <param name="graphQLClient">The GraphQLClient</param>
/// <param name="cancellationToken"></param>
/// <returns>The GraphQLResponse</returns>
public static async Task<GraphQLResponse> PostIntrospectionQueryAsync(this GraphQLClient graphQLClient) =>
await graphQLClient.PostAsync(IntrospectionQuery).ConfigureAwait(false);
public static async Task<GraphQLResponse> PostIntrospectionQueryAsync(this GraphQLClient graphQLClient, CancellationToken cancellationToken = default) =>
await graphQLClient.PostAsync(IntrospectionGraphQLRequest, cancellationToken).ConfigureAwait(false);

}

Expand Down
24 changes: 24 additions & 0 deletions src/GraphQL.Client/GraphQLSubscriptionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using GraphQL.Common.Response;

namespace GraphQL.Client {

/// <summary>
/// Represents the result of a subscription query
/// </summary>
[Obsolete("EXPERIMENTAL API")]
public class GraphQLSubscriptionResult {

public event Action<GraphQLResponse> OnReceive;

public GraphQLResponse LastResponse { get; }

public GraphQLSubscriptionResult() {
this.OnReceive.Invoke(null);
}

}

}