Skip to content

Commit aadf594

Browse files
authored
Merge pull request #226 from graphql-dotnet/non-generic-interface-for-response
Non generic interface for GraphQLResponse
2 parents 98cb88d + c58dc9e commit aadf594

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

GraphQL.Client.sln

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Server.Test", "test
3333
EndProject
3434
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{05CAF9B2-981E-40C0-AE31-5FA56E351F12}"
3535
ProjectSection(SolutionItems) = preProject
36-
.github\workflows\branches-ubuntu.yml = .github\workflows\branches-ubuntu.yml
3736
.github\workflows\branches.yml = .github\workflows\branches.yml
38-
.github\workflows\main.yml = .github\workflows\main.yml
37+
.github\workflows\master.yml = .github\workflows\master.yml
3938
EndProjectSection
4039
EndProject
4140
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Primitives", "src\GraphQL.Primitives\GraphQL.Primitives.csproj", "{87FC440E-6A4D-47D8-9EB2-416FC31CC4A6}"
@@ -64,7 +63,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Serializer.S
6463
EndProject
6564
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{89AD33AB-64F6-4F82-822F-21DF7A10CEC0}"
6665
EndProject
67-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Client.Example", "examples\GraphQL.Client.Example\GraphQL.Client.Example.csproj", "{6B13B87D-1EF4-485F-BC5D-891E2F4DA6CD}"
66+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Example", "examples\GraphQL.Client.Example\GraphQL.Client.Example.csproj", "{6B13B87D-1EF4-485F-BC5D-891E2F4DA6CD}"
6867
EndProject
6968
Global
7069
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/GraphQL.Primitives/GraphQLResponse.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
namespace GraphQL
77
{
88

9-
public class GraphQLResponse<T> : IEquatable<GraphQLResponse<T>?>
9+
public class GraphQLResponse<T> : IGraphQLResponse, IEquatable<GraphQLResponse<T>?>
1010
{
1111

1212
[DataMember(Name = "data")]
1313
public T Data { get; set; }
14+
object IGraphQLResponse.Data => Data;
1415

1516
[DataMember(Name = "errors")]
1617
public GraphQLError[]? Errors { get; set; }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace GraphQL
2+
{
3+
public interface IGraphQLResponse
4+
{
5+
object Data { get; }
6+
7+
GraphQLError[]? Errors { get; set; }
8+
9+
Map? Extensions { get; set; }
10+
}
11+
}

tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public void InEquality1Fact()
7575
[Fact]
7676
public void InEquality2Fact()
7777
{
78-
GraphQLRequest graphQLRequest1 = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName");
79-
GraphQLRequest graphQLRequest2 = new GraphQLRequest("{hero{name}}", new { varName = "varValue2" }, "operationName");
78+
var graphQLRequest1 = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName");
79+
var graphQLRequest2 = new GraphQLRequest("{hero{name}}", new { varName = "varValue2" }, "operationName");
8080
Assert.NotEqual(graphQLRequest1, graphQLRequest2);
8181
}
8282

@@ -122,8 +122,11 @@ public void PropertyQueryGetFact()
122122
[Fact]
123123
public void PropertyQuerySetFact()
124124
{
125-
var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName");
126-
graphQLRequest.Query = "{hero{name2}}";
125+
var graphQLRequest =
126+
new GraphQLRequest("{hero{name}}", new {varName = "varValue1"}, "operationName")
127+
{
128+
Query = "{hero{name2}}"
129+
};
127130
Assert.Equal("{hero{name2}}", graphQLRequest.Query);
128131
}
129132

@@ -144,8 +147,10 @@ public void PropertyOperationNameNullGetFact()
144147
[Fact]
145148
public void PropertyOperationNameSetFact()
146149
{
147-
var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue" }, "operationName1");
148-
graphQLRequest.OperationName = "operationName2";
150+
var graphQLRequest = new GraphQLRequest("{hero{name}}", new {varName = "varValue"}, "operationName1")
151+
{
152+
OperationName = "operationName2"
153+
};
149154
Assert.Equal("operationName2", graphQLRequest.OperationName);
150155
}
151156

@@ -166,10 +171,9 @@ public void PropertyVariableNullGetFact()
166171
[Fact]
167172
public void PropertyVariableSetFact()
168173
{
169-
var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName1");
170-
graphQLRequest.Variables = new
174+
var graphQLRequest = new GraphQLRequest("{hero{name}}", new {varName = "varValue1"}, "operationName1")
171175
{
172-
varName = "varValue2"
176+
Variables = new {varName = "varValue2"}
173177
};
174178
Assert.Equal(new
175179
{

0 commit comments

Comments
 (0)