diff --git a/README.md b/README.md index 4a93325..0c6bcaf 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Sample/Program.cs b/Sample/Program.cs index b288b19..da0831f 100644 --- a/Sample/Program.cs +++ b/Sample/Program.cs @@ -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(); - }); - } -} +builder.Services + .AddGraphQLServer() + .AddArgumentValidator() + .AddQueryType(); +builder.Services + .AddSingleton(); + +var app = builder.Build(); + +app.MapGraphQL(); + +app.Run(); \ No newline at end of file diff --git a/Sample/Sample.csproj b/Sample/Sample.csproj index 62e28ce..1c35cab 100644 --- a/Sample/Sample.csproj +++ b/Sample/Sample.csproj @@ -1,11 +1,13 @@ - netcoreapp3.1 + net6.0 + enable + enable - + diff --git a/Sample/Startup.cs b/Sample/Startup.cs deleted file mode 100644 index 41338b1..0000000 --- a/Sample/Startup.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Graph.ArgumentValidator; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Shared; - -namespace Sample -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers(); - services.AddGraphQLServer() - .AddArgumentValidator() - .AddQueryType(); - - services.AddSingleton(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseHttpsRedirection(); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - endpoints.MapGraphQL(); - }); - } - } -} diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 494ddf5..9e6616f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -16,7 +16,7 @@ $(MSBuildProjectName) MIT - 2.1.1 + 3.0.0 net6.0;net5.0; netcoreapp3.1; netstandard2.0 net6.0;net5.0; netcoreapp3.1; netcoreapp2.1 diff --git a/src/Graph.ArgumentValidator.csproj b/src/Graph.ArgumentValidator.csproj index 34c6617..b5eb0c8 100644 --- a/src/Graph.ArgumentValidator.csproj +++ b/src/Graph.ArgumentValidator.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/ValidationMiddleware.cs b/src/ValidationMiddleware.cs index 52f422f..afc5d7b 100644 --- a/src/ValidationMiddleware.cs +++ b/src/ValidationMiddleware.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; +using HotChocolate.Execution; namespace Graph.ArgumentValidator { @@ -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()); } diff --git a/src/ValidationTypeInterceptor.cs b/src/ValidationTypeInterceptor.cs index fe46b58..f3509f6 100644 --- a/src/ValidationTypeInterceptor.cs +++ b/src/ValidationTypeInterceptor.cs @@ -15,8 +15,7 @@ internal class ValidationTypeInterceptor : TypeInterceptor public override void OnBeforeCompleteType( ITypeCompletionContext completionContext, - DefinitionBase definition, - IDictionary contextData) + DefinitionBase definition) { if (definition is ObjectTypeDefinition objectTypeDef) {