Skip to content

Commit f501e5d

Browse files
authored
Merge pull request #205 from graphql-dotnet/fix-constructor-parameter-checks
Fix constructor parameter checks
2 parents 6e38798 + f2a6954 commit f501e5d

File tree

9 files changed

+12
-38
lines changed

9 files changed

+12
-38
lines changed

src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<Import Project="../src.props" />
33

44
<PropertyGroup>
5-
<TargetFramework>netstandard2.0</TargetFramework>
5+
<Description>Abstractions for the Websocket transport used in GraphQL.Client</Description>
6+
<TargetFramework>netstandard2.0</TargetFramework>
67
<LangVersion>8.0</LangVersion>
78
</PropertyGroup>
89

src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="../src.props" />
44

55
<PropertyGroup>
6-
<Description>A GraphQL Client</Description>
6+
<Description>Abstractions for GraphQL.Client</Description>
77
<RootNamespace>GraphQL.Client.Abstractions</RootNamespace>
88
<TargetFrameworks>netstandard2.0</TargetFrameworks>
99
</PropertyGroup>

src/GraphQL.Client.Abstractions/GraphQLJsonSerializerExtensions.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
using System;
2-
using System.Linq;
32

43
namespace GraphQL.Client.Abstractions
54
{
65
public static class GraphQLJsonSerializerExtensions
76
{
8-
public static TSerializerInterface EnsureAssigned<TSerializerInterface>(this TSerializerInterface jsonSerializer) where TSerializerInterface : IGraphQLJsonSerializer
9-
{
10-
// if no serializer was assigned
11-
if (jsonSerializer == null)
12-
{
13-
// try to find one in the assembly and assign that
14-
var type = typeof(TSerializerInterface);
15-
var serializerType = AppDomain.CurrentDomain
16-
.GetAssemblies()
17-
.SelectMany(s => s.GetTypes())
18-
.FirstOrDefault(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
19-
if (serializerType == null)
20-
throw new InvalidOperationException($"no implementation of \"{type}\" found");
21-
22-
jsonSerializer = (TSerializerInterface)Activator.CreateInstance(serializerType);
23-
}
24-
25-
return jsonSerializer;
26-
}
27-
287
public static TOptions New<TOptions>(this Action<TOptions> configure) =>
298
configure.AndReturn(Activator.CreateInstance<TOptions>());
309

src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="../src.props" />
44

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

src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ namespace GraphQL.Client.LocalExecution
1818
{
1919
public static class GraphQLLocalExecutionClient
2020
{
21-
public static GraphQLLocalExecutionClient<TSchema> New<TSchema>(TSchema schema) where TSchema : ISchema
22-
=> new GraphQLLocalExecutionClient<TSchema>(schema);
23-
2421
public static GraphQLLocalExecutionClient<TSchema> New<TSchema>(TSchema schema, IGraphQLJsonSerializer serializer) where TSchema : ISchema
2522
=> new GraphQLLocalExecutionClient<TSchema>(schema, serializer);
2623
}
@@ -46,20 +43,16 @@ public class GraphQLLocalExecutionClient<TSchema> : IGraphQLClient where TSchema
4643

4744
private readonly DocumentExecuter _documentExecuter;
4845

49-
public GraphQLLocalExecutionClient(TSchema schema)
46+
public GraphQLLocalExecutionClient(TSchema schema, IGraphQLJsonSerializer serializer)
5047
{
51-
Serializer.EnsureAssigned();
52-
Schema = schema;
48+
Schema = schema ?? throw new ArgumentNullException(nameof(schema), "no schema configured");
49+
Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");
50+
5351
if (!Schema.Initialized)
5452
Schema.Initialize();
5553
_documentExecuter = new DocumentExecuter();
5654
}
57-
58-
public GraphQLLocalExecutionClient(TSchema schema, IGraphQLJsonSerializer serializer) : this(schema)
59-
{
60-
Serializer = serializer;
61-
}
62-
55+
6356
public void Dispose() { }
6457

6558
public Task<GraphQLResponse<TResponse>> SendQueryAsync<TResponse>(GraphQLRequest request, CancellationToken cancellationToken = default)

src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Import Project="../src.props" />
33

44
<PropertyGroup>
5+
<Description>A serializer implementation for GraphQL.Client using Newtonsoft.Json as underlying JSON library</Description>
56
<TargetFrameworks>netstandard2.0</TargetFrameworks>
67
<LangVersion>8.0</LangVersion>
78
</PropertyGroup>

src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Import Project="../src.props" />
33

44
<PropertyGroup>
5+
<Description>A serializer implementation for GraphQL.Client using System.Text.Json as underlying JSON library</Description>
56
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
67
<LangVersion>8.0</LangVersion>
78
</PropertyGroup>

src/GraphQL.Client/GraphQL.Client.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626

2727
<ItemGroup>
28-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2928
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
3029
</ItemGroup>
3130

src/GraphQL.Client/GraphQLHttpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public GraphQLHttpClient(Action<GraphQLHttpClientOptions> configure, IGraphQLWeb
5858
public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer, HttpClient httpClient)
5959
{
6060
Options = options ?? throw new ArgumentNullException(nameof(options));
61-
JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
61+
JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");
6262
HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
6363
_graphQlHttpWebSocket = new GraphQLHttpWebSocket(GetWebSocketUri(), this);
6464
}

0 commit comments

Comments
 (0)