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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<Import Project="../src.props" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Abstractions for the Websocket transport used in GraphQL.Client</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="../src.props" />

<PropertyGroup>
<Description>A GraphQL Client</Description>
<Description>Abstractions for GraphQL.Client</Description>
<RootNamespace>GraphQL.Client.Abstractions</RootNamespace>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
Expand Down
21 changes: 0 additions & 21 deletions src/GraphQL.Client.Abstractions/GraphQLJsonSerializerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
using System;
using System.Linq;

namespace GraphQL.Client.Abstractions
{
public static class GraphQLJsonSerializerExtensions
{
public static TSerializerInterface EnsureAssigned<TSerializerInterface>(this TSerializerInterface jsonSerializer) where TSerializerInterface : IGraphQLJsonSerializer
{
// if no serializer was assigned
if (jsonSerializer == null)
{
// try to find one in the assembly and assign that
var type = typeof(TSerializerInterface);
var serializerType = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(s => s.GetTypes())
.FirstOrDefault(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
if (serializerType == null)
throw new InvalidOperationException($"no implementation of \"{type}\" found");

jsonSerializer = (TSerializerInterface)Activator.CreateInstance(serializerType);
}

return jsonSerializer;
}

public static TOptions New<TOptions>(this Action<TOptions> configure) =>
configure.AndReturn(Activator.CreateInstance<TOptions>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="../src.props" />

<PropertyGroup>
<Description>A GraphQL Client which executes the queries directly on a provided C# schema</Description>
<Description>A GraphQL Client which executes the queries directly on a provided GraphQL schema using graphql-dotnet</Description>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

Expand Down
17 changes: 5 additions & 12 deletions src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ namespace GraphQL.Client.LocalExecution
{
public static class GraphQLLocalExecutionClient
{
public static GraphQLLocalExecutionClient<TSchema> New<TSchema>(TSchema schema) where TSchema : ISchema
=> new GraphQLLocalExecutionClient<TSchema>(schema);

public static GraphQLLocalExecutionClient<TSchema> New<TSchema>(TSchema schema, IGraphQLJsonSerializer serializer) where TSchema : ISchema
=> new GraphQLLocalExecutionClient<TSchema>(schema, serializer);
}
Expand All @@ -46,20 +43,16 @@ public class GraphQLLocalExecutionClient<TSchema> : IGraphQLClient where TSchema

private readonly DocumentExecuter _documentExecuter;

public GraphQLLocalExecutionClient(TSchema schema)
public GraphQLLocalExecutionClient(TSchema schema, IGraphQLJsonSerializer serializer)
{
Serializer.EnsureAssigned();
Schema = schema;
Schema = schema ?? throw new ArgumentNullException(nameof(schema), "no schema configured");
Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");

if (!Schema.Initialized)
Schema.Initialize();
_documentExecuter = new DocumentExecuter();
}

public GraphQLLocalExecutionClient(TSchema schema, IGraphQLJsonSerializer serializer) : this(schema)
{
Serializer = serializer;
}


public void Dispose() { }

public Task<GraphQLResponse<TResponse>> SendQueryAsync<TResponse>(GraphQLRequest request, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Import Project="../src.props" />

<PropertyGroup>
<Description>A serializer implementation for GraphQL.Client using Newtonsoft.Json as underlying JSON library</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Import Project="../src.props" />

<PropertyGroup>
<Description>A serializer implementation for GraphQL.Client using System.Text.Json as underlying JSON library</Description>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/GraphQL.Client/GraphQL.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Client/GraphQLHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public GraphQLHttpClient(Action<GraphQLHttpClientOptions> configure, IGraphQLWeb
public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer, HttpClient httpClient)
{
Options = options ?? throw new ArgumentNullException(nameof(options));
JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");
HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
_graphQlHttpWebSocket = new GraphQLHttpWebSocket(GetWebSocketUri(), this);
}
Expand Down