Skip to content

Commit 29e5260

Browse files
authored
GraphQL 7 (#685)
1 parent 8d64596 commit 29e5260

12 files changed

Lines changed: 92 additions & 117 deletions

readme.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,20 @@ public class Query :
210210
ObjectGraphType
211211
{
212212
public Query() =>
213-
Field<ResultGraph>(
214-
"inputQuery",
215-
arguments: new(
216-
new QueryArgument<MyInputGraph>
213+
Field<ResultGraph>("inputQuery")
214+
.Argument<MyInputGraph>("input")
215+
.Resolve(context =>
217216
{
218-
Name = "input"
217+
var input = context.GetValidatedArgument<MyInput>("input");
218+
return new Result
219+
{
220+
Data = input.Content
221+
};
219222
}
220-
),
221-
resolve: context =>
222-
{
223-
var input = context.GetValidatedArgument<MyInput>("input");
224-
return new Result
225-
{
226-
Data = input.Content
227-
};
228-
}
229-
);
223+
);
230224
}
231225
```
232-
<sup><a href='/src/SampleWeb/Query.cs#L4-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-getvalidatedargument' title='Start of snippet'>anchor</a></sup>
226+
<sup><a href='/src/SampleWeb/Query.cs#L4-L23' title='Snippet source file'>snippet source</a> | <a href='#snippet-getvalidatedargument' title='Start of snippet'>anchor</a></sup>
233227
<!-- endSnippet -->
234228

235229

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>7.2.1</Version>
3+
<Version>8.0.0</Version>
44
<AssemblyVersion>1.0.0</AssemblyVersion>
55
<PackageTags>GraphQL, Validation, FluentValidation</PackageTags>
66
<Description>Add FluentValidation (https://fluentvalidation.net/) support to GraphQL.net (https://github.com/graphql-dotnet/graphql-dotnet)</Description>

src/GraphQL.FluentValidation/GraphQL.FluentValidation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageReference Include="FluentValidation" Version="11.2.0" />
7-
<PackageReference Include="GraphQL" Version="5.3.3" />
7+
<PackageReference Include="GraphQL" Version="7.0.1" />
88
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
99
<PackageReference Include="ProjectDefaults" Version="1.0.80" PrivateAssets="all" />
1010
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />

src/SampleWeb.Tests/GraphQLControllerTests.RunQuery.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Status: 200 OK,
44
Content: {
55
Headers: {
6-
Content-Type: application/json
6+
Content-Type: application/graphql+json; charset=utf-8
77
},
88
Value: {
99
data: {

src/SampleWeb.Tests/SampleWeb.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageReference Include="Verify.DiffPlex" Version="1.3.0" />
7-
<PackageReference Include="GraphQL" Version="5.3.3" />
7+
<PackageReference Include="GraphQL" Version="7.0.1" />
88
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.8" />
99
<PackageReference Include="Xunit" Version="2.4.2" />
1010
<PackageReference Include="Verify.Xunit" Version="17.10.2" />

src/SampleWeb/Query.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@ public class Query :
77
ObjectGraphType
88
{
99
public Query() =>
10-
Field<ResultGraph>(
11-
"inputQuery",
12-
arguments: new(
13-
new QueryArgument<MyInputGraph>
10+
Field<ResultGraph>("inputQuery")
11+
.Argument<MyInputGraph>("input")
12+
.Resolve(context =>
1413
{
15-
Name = "input"
14+
var input = context.GetValidatedArgument<MyInput>("input");
15+
return new Result
16+
{
17+
Data = input.Content
18+
};
1619
}
17-
),
18-
resolve: context =>
19-
{
20-
var input = context.GetValidatedArgument<MyInput>("input");
21-
return new Result
22-
{
23-
Data = input.Content
24-
};
25-
}
26-
);
20+
);
2721
}
2822

2923
#endregion

src/SampleWeb/SampleWeb.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<Folder Include="wwwroot\" />
7-
<PackageReference Include="GraphQL" Version="5.3.3" />
8-
<PackageReference Include="GraphQL.MicrosoftDI" Version="5.3.3" />
7+
<PackageReference Include="GraphQL" Version="7.0.1" />
8+
<PackageReference Include="GraphQL.MicrosoftDI" Version="7.0.1" />
99
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.0" />
10-
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="6.1.1" />
11-
<PackageReference Include="GraphQL.SystemTextJson" Version="5.3.3" />
12-
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="6.1.1" />
10+
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="7.0.0" />
11+
<PackageReference Include="GraphQL.SystemTextJson" Version="7.0.1" />
12+
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="7.0.0" />
1313
<ProjectReference Include="..\GraphQL.FluentValidation\GraphQL.FluentValidation.csproj" />
1414
<PackageReference Include="ProjectDefaults" Version="1.0.80" PrivateAssets="all" />
1515
</ItemGroup>

src/SampleWeb/Startup.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using FluentValidation;
22
using GraphQL;
3-
using GraphQL.MicrosoftDI;
4-
using GraphQL.Server;
5-
using GraphQL.SystemTextJson;
63
using GraphQL.Types;
74

85
public class Startup
@@ -16,7 +13,6 @@ public void ConfigureServices(IServiceCollection services)
1613

1714
services.AddValidatorsFromAssemblyContaining<Startup>();
1815
services.AddGraphQL(builder => builder
19-
.AddHttpMiddleware<Schema>()
2016
.AddSchema<Schema>()
2117
.ConfigureExecutionOptions(options =>
2218
{

src/Tests/Arguments/ComplexInputInnerGraph.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ public class ComplexInputInnerGraph :
44
InputObjectGraphType<ComplexInputInner>
55
{
66
public ComplexInputInnerGraph() =>
7-
Field<StringGraphType, string?>()
8-
.Name("content")
7+
Field<StringGraphType, string?>("content")
98
.Resolve(ctx => ctx.Source.Content);
109
}

src/Tests/Arguments/ComplexInputListItemGraph.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ public class ComplexInputListItemGraph :
55
{
66
public ComplexInputListItemGraph()
77
{
8-
Field<NonNullGraphType<IntGraphType>>()
9-
.Name("id")
8+
Field<NonNullGraphType<IntGraphType>>("id")
109
.Resolve(ctx => ctx.Source.Id);
1110

12-
Field<StringGraphType, string?>()
13-
.Name("content")
11+
Field<StringGraphType, string?>("content")
1412
.Resolve(ctx => ctx.Source.Content);
1513
}
1614
}

0 commit comments

Comments
 (0)