Skip to content

Commit

Permalink
Merge pull request #9 from snifter/master
Browse files Browse the repository at this point in the history
Support for HotChocolate v13
  • Loading branch information
VarunSaiTeja authored Oct 11, 2023
2 parents b5e8574 + 0dadc6b commit e3e9a95
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 78 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ As HotChocolate doesn't validate input arguments, After installing this package,
[!["Buy Me A Coffee"](https://cdn.buymeacoffee.com/assets/img/home-page-v3/bmc-new-logo.png)](https://www.buymeacoffee.com/varunteja)


**Installation Note**:
**Installation Note**:

Use Graph.ArgumentValidator v3.0.0 if you are using HotChocolate v13.

Use Graph.ArgumentValidator v2.0.0 if you are using HotChocolate v12.

Expand Down
33 changes: 15 additions & 18 deletions Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Graph.ArgumentValidator;
using Shared;

namespace Sample
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var builder = WebApplication.CreateBuilder(args);

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
builder.Services
.AddGraphQLServer()
.AddArgumentValidator()
.AddQueryType<Query>();
builder.Services
.AddSingleton<DuplicateEmailValidatorService>();

var app = builder.Build();

app.MapGraphQL();

app.Run();
6 changes: 4 additions & 2 deletions Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HotChocolate.AspNetCore" Version="12.6.2" />
<PackageReference Include="HotChocolate.AspNetCore" Version="13.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 0 additions & 52 deletions Sample/Startup.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<Version>2.1.1</Version>
<Version>3.0.0</Version>

<LibraryTargetFrameworks>net6.0;net5.0; netcoreapp3.1; netstandard2.0</LibraryTargetFrameworks>
<TestTargetFrameworks>net6.0;net5.0; netcoreapp3.1; netcoreapp2.1</TestTargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion src/Graph.ArgumentValidator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HotChocolate.Execution" Version="12.6.2" />
<PackageReference Include="HotChocolate.Execution" Version="13.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/ValidationMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using HotChocolate.Execution;

namespace Graph.ArgumentValidator
{
Expand Down Expand Up @@ -41,7 +42,7 @@ public async Task InvokeAsync(IMiddlewareContext context)
context.ReportError(ErrorBuilder.New()
.SetMessage(validationResult.ErrorMessage)
.SetExtension("field", char.ToLowerInvariant(field[0]) + field.Substring(1))
.SetPath(Path.New(argument.Name))
.SetPath(PathFactory.Instance.New(argument.Name))
.Build());
}

Expand Down
3 changes: 1 addition & 2 deletions src/ValidationTypeInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ internal class ValidationTypeInterceptor : TypeInterceptor

public override void OnBeforeCompleteType(
ITypeCompletionContext completionContext,
DefinitionBase definition,
IDictionary<string, object> contextData)
DefinitionBase definition)
{
if (definition is ObjectTypeDefinition objectTypeDef)
{
Expand Down

0 comments on commit e3e9a95

Please sign in to comment.