diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/DataLoaderWithEFCore.csproj b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/DataLoaderWithEFCore.csproj
index fc68a5b6..3eb7f2b7 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/DataLoaderWithEFCore.csproj
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/DataLoaderWithEFCore.csproj
@@ -1,13 +1,10 @@
- netcoreapp2.1
+ net6.0
+ 9.0
-
-
- 7.3
-
-
+
@@ -16,12 +13,13 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/GraphController.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/GraphController.cs
index 23f86040..e9da09dc 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/GraphController.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/GraphController.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
-using GraphQL;
using GraphQL.Conventions;
using Microsoft.AspNetCore.Mvc;
@@ -13,13 +12,11 @@ namespace DataLoaderWithEFCore.GraphApi
public class GraphController : ControllerBase
{
private readonly GraphQLEngine _engine;
- private readonly IUserContext _userContext;
private readonly IDependencyInjector _injector;
- public GraphController(GraphQLEngine engine, IUserContext userContext, IDependencyInjector injector)
+ public GraphController(GraphQLEngine engine, IDependencyInjector injector)
{
_engine = engine;
- _userContext = userContext;
_injector = injector;
}
@@ -30,12 +27,11 @@ public async Task Post()
using (var reader = new StreamReader(Request.Body))
requestBody = await reader.ReadToEndAsync();
- ExecutionResult result = await _engine
+ var result = await _engine
.NewExecutor()
- .WithUserContext(_userContext)
.WithDependencyInjector(_injector)
.WithRequest(requestBody)
- .Execute();
+ .ExecuteAsync();
var responseBody = _engine.SerializeResult(result);
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Mutation.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Mutation.cs
index b3a8da26..addf053f 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Mutation.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Mutation.cs
@@ -7,7 +7,14 @@ namespace DataLoaderWithEFCore.GraphApi.Schema
{
public sealed class Mutation
{
+ private readonly IMapper _mapper;
+
+ public Mutation(IMapper mapper)
+ {
+ _mapper = mapper;
+ }
+
public async Task UpdateMovieTitle([Inject] IMovieRepository movieRepository, UpdateMovieTitleParams @params)
- => Mapper.Map(await movieRepository.UpdateMovieTitle(@params.Id, @params.NewTitle));
+ => _mapper.Map(await movieRepository.UpdateMovieTitle(@params.Id, @params.NewTitle));
}
}
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Actor.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Actor.cs
index 88c3a73b..0a345a7e 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Actor.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Actor.cs
@@ -18,10 +18,10 @@ public sealed class Actor
public Guid MovieId { get; set; }
- public async Task Country([Inject] ICountryRepository repository, [Inject] DataLoaderContext dataLoaderContext)
+ public async Task Country([Inject] IMapper mapper, [Inject] ICountryRepository repository, [Inject] DataLoaderContext dataLoaderContext)
{
var loader = dataLoaderContext.GetOrAddBatchLoader("Actor_Country", repository.GetCountries);
- return Mapper.Map(await loader.LoadAsync(CountryCode));
+ return mapper.Map(await loader.LoadAsync(CountryCode).GetResultAsync());
}
}
}
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Movie.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Movie.cs
index bd2bcd15..292837d0 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Movie.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/OutputTypes/Movie.cs
@@ -18,10 +18,10 @@ public sealed class Movie
public DateTime ReleaseDateUtc { get; set; }
- public async Task Actors([Inject] IActorRepository repository, [Inject] DataLoaderContext dataLoaderContext)
+ public async Task Actors([Inject] IMapper mapper, [Inject] IActorRepository repository, [Inject] DataLoaderContext dataLoaderContext)
{
var loader = dataLoaderContext.GetOrAddCollectionBatchLoader("Movie_Actors", repository.GetActorsPerMovie);
- return Mapper.Map(await loader.LoadAsync(Id));
+ return mapper.Map(await loader.LoadAsync(Id).GetResultAsync());
}
}
}
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Query.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Query.cs
index c1e25aca..7ed3fec5 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Query.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/Schema/Query.cs
@@ -8,10 +8,19 @@ namespace DataLoaderWithEFCore.GraphApi.Schema
{
public sealed class Query
{
+ private readonly IMapper _mapper;
+
+ public Query(IMapper mapper)
+ {
+ _mapper = mapper;
+ }
+
public async Task Movie([Inject] IMovieRepository repository, Guid id)
- => Mapper.Map(await repository.FindMovie(id));
+ {
+ return _mapper.Map(await repository.FindMovie(id));
+ }
public async Task Movies([Inject] IMovieRepository repository)
- => Mapper.Map(await repository.GetMovies());
+ => _mapper.Map(await repository.GetMovies());
}
}
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/UserContext.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/UserContext.cs
deleted file mode 100644
index cb837e7e..00000000
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/GraphApi/UserContext.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Threading;
-using System.Threading.Tasks;
-using GraphQL.Conventions;
-using GraphQL.DataLoader;
-
-namespace DataLoaderWithEFCore.GraphApi
-{
- public class UserContext : IUserContext, IDataLoaderContextProvider
- {
- public DataLoaderContext _context { get; private set; }
-
- public UserContext(DataLoaderContext context)
- {
- _context = context;
- }
-
- public Task FetchData(CancellationToken token)
- {
- return _context.DispatchAllAsync(token);
- }
- }
-}
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Program.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Program.cs
index 4087848e..89d06431 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Program.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace DataLoaderWithEFCore
{
diff --git a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Startup.cs b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Startup.cs
index 9cdeb38e..a39d0611 100644
--- a/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Startup.cs
+++ b/samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Startup.cs
@@ -10,6 +10,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Schema = DataLoaderWithEFCore.GraphApi.Schema;
namespace DataLoaderWithEFCore
@@ -26,8 +27,6 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
- services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
-
services.AddDbContext(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
@@ -35,22 +34,21 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped();
services.AddScoped();
- services.AddSingleton(provider => new GraphQLEngine()
+ services.AddSingleton(_ => new GraphQLEngine()
.WithFieldResolutionStrategy(FieldResolutionStrategy.Normal)
.BuildSchema(typeof(SchemaDefinition)));
services.AddScoped();
- services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
-
- Mapper.Initialize(config => config.AddProfile());
+ services.AddAutoMapper(typeof(Mappings));
+ services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
@@ -62,7 +60,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}
app.UseHttpsRedirection();
- app.UseMvc();
+ app.UseRouting();
+ app.UseEndpoints(configure =>
+ {
+ configure.MapControllers();
+ });
}
}
}
diff --git a/samples/SimpleWebApp/Program.cs b/samples/SimpleWebApp/Program.cs
index e3bb7ab0..8196fc17 100644
--- a/samples/SimpleWebApp/Program.cs
+++ b/samples/SimpleWebApp/Program.cs
@@ -1,6 +1,6 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
namespace GraphQL.Conventions.Tests.Server
{
@@ -13,6 +13,7 @@ public static void Main(string[] args)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup()
+ .ConfigureLogging(l => l.AddConsole())
.Build();
host.Run();
diff --git a/samples/SimpleWebApp/Properties/launchSettings.json b/samples/SimpleWebApp/Properties/launchSettings.json
new file mode 100644
index 00000000..786098f4
--- /dev/null
+++ b/samples/SimpleWebApp/Properties/launchSettings.json
@@ -0,0 +1,12 @@
+{
+ "profiles": {
+ "SimpleWebApp": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "https://localhost:64575;http://localhost:64576"
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/SimpleWebApp/SimpleWebApp.csproj b/samples/SimpleWebApp/SimpleWebApp.csproj
index 874898c2..f4aedde6 100755
--- a/samples/SimpleWebApp/SimpleWebApp.csproj
+++ b/samples/SimpleWebApp/SimpleWebApp.csproj
@@ -1,11 +1,9 @@
- netcoreapp1.0
-
-
-
- 7.3
+ net6.0
+ 9.0
+ GraphQL.Conventions.Tests.Server
@@ -13,7 +11,6 @@
-
diff --git a/samples/SimpleWebApp/Startup.cs b/samples/SimpleWebApp/Startup.cs
index 09181ac8..177b90fe 100644
--- a/samples/SimpleWebApp/Startup.cs
+++ b/samples/SimpleWebApp/Startup.cs
@@ -21,8 +21,6 @@ public void ConfigureServices(IServiceCollection services)
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
- loggerFactory.AddConsole();
-
var dependencyInjector = new DependencyInjector();
dependencyInjector.Register(new BookRepository());
dependencyInjector.Register(new AuthorRepository());
@@ -54,10 +52,10 @@ private async Task HandleRequest(HttpContext context)
var body = streamReader.ReadToEnd();
var userContext = new UserContext();
var result = await _requestHandler
- .ProcessRequest(Request.New(body), userContext);
+ .ProcessRequestAsync(Request.New(body), userContext);
context.Response.Headers.Add("Content-Type", "application/json; charset=utf-8");
context.Response.StatusCode = result.Errors?.Count > 0 ? 400 : 200;
- await context.Response.WriteAsync(result.Body);
+ await context.Response.WriteAsync(result.GetBody());
}
}
}
diff --git a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Controllers/GraphController.cs b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Controllers/GraphController.cs
deleted file mode 100644
index cc8971c9..00000000
--- a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Controllers/GraphController.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using GraphQL;
-using GraphQL.Conventions;
-using Microsoft.AspNetCore.Mvc;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Threading.Tasks;
-
-namespace SubscriptionExample.Controllers
-{
- [ApiController]
- [Route("graphql")]
- public sealed class GraphController : ControllerBase
- {
- private readonly GraphQLEngine _engine;
- private readonly IDependencyInjector _injector;
-
- public GraphController(GraphQLEngine engine, IDependencyInjector injector)
- {
- _engine = engine;
- _injector = injector;
- }
-
- [HttpPost]
- public async Task Post()
- {
- string requestBody;
- using (var reader = new StreamReader(Request.Body))
- requestBody = await reader.ReadToEndAsync();
-
- ExecutionResult result = await _engine
- .NewExecutor()
- .WithDependencyInjector(_injector)
- .WithRequest(requestBody)
- .Execute();
-
- var responseBody = _engine.SerializeResult(result);
-
- HttpStatusCode statusCode = HttpStatusCode.OK;
-
- if (result.Errors?.Any() ?? false)
- {
- statusCode = HttpStatusCode.InternalServerError;
- if (result.Errors.Any(x => x.Code == "VALIDATION_ERROR"))
- statusCode = HttpStatusCode.BadRequest;
- else if (result.Errors.Any(x => x.Code == "UNAUTHORIZED_ACCESS"))
- statusCode = HttpStatusCode.Forbidden;
- }
-
- return new ContentResult
- {
- Content = responseBody,
- ContentType = "application/json; charset=utf-8",
- StatusCode = (int)statusCode
- };
- }
- }
-}
\ No newline at end of file
diff --git a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Program.cs b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Program.cs
index ea9359a1..88d3c43f 100644
--- a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Program.cs
+++ b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace SubscriptionExample
{
diff --git a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Startup.cs b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Startup.cs
index a3083a2d..de46d0ec 100644
--- a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Startup.cs
+++ b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/Startup.cs
@@ -1,20 +1,25 @@
-using GraphQL;
+using System.Threading.Tasks;
+using GraphQL;
using GraphQL.Conventions;
using GraphQL.Conventions.Adapters;
using GraphQL.Conventions.Builders;
-using GraphQL.Http;
+using GraphQL.Conventions.Types.Resolution;
+using GraphQL.DataLoader;
+using GraphQL.MicrosoftDI;
+using GraphQL.NewtonsoftJson;
using GraphQL.Server;
-using GraphQL.Server.Internal;
-using GraphQL.Server.Transports.Subscriptions.Abstractions;
-using GraphQL.Server.Transports.WebSockets;
-using GraphQL.Server.Ui.Playground;
+using GraphQL.Server.Transports.AspNetCore;
+using GraphQL.SystemTextJson;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-using Newtonsoft.Json;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using SubscriptionExample.Core;
+using SubscriptionExample.GraphQl;
+using DocumentExecuter = GraphQL.Conventions.DocumentExecuter;
namespace SubscriptionExample
{
@@ -24,49 +29,63 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
- var typeAdapter = new GraphTypeAdapter();
- var constructor = new SchemaConstructor(typeAdapter);
- var schema = constructor.Build(typeof(SchemaDefinition));
- var graphQLEngine = new GraphQLEngine()
+ services.AddSingleton();
+
+ // Graph QL Server Services
+ services.AddGraphQL(builder =>
+ {
+ builder
+ .AddHttpMiddleware>()
+ .AddWebSocketsHttpMiddleware()
+ .AddDefaultEndpointSelectorPolicy()
+ .AddSystemTextJson()
+ .AddErrorInfoProvider(option =>
+ {
+ option.ExposeExceptionStackTrace = true;
+ })
+ .AddDataLoader()
+ .AddWebSockets()
+ .ConfigureExecutionOptions(options =>
+ {
+ options.EnableMetrics = true;
+ var logger = options.RequestServices.GetRequiredService>();
+ options.UnhandledExceptionDelegate = ctx =>
+ {
+ logger.LogError($"GraphQL Unhandled Exception: {ctx.ErrorMessage}.", ctx.OriginalException);
+ return Task.CompletedTask;
+ };
+ });
+ });
+
+ // Graph QL Convention: Engine and Schema
+ var engine = new GraphQLEngine()
.WithFieldResolutionStrategy(FieldResolutionStrategy.Normal)
- .WithQuery()
- .WithMutation()
- .WithSubscription()
+ .WithQuery()
+ .WithMutation()
+ .WithSubscription()
.BuildSchema();
- services.AddSingleton();
+ var schema = engine.GetSchema();
+
+ // Add Graph QL Convention Services
+ services.AddSingleton(engine);
services.AddSingleton(schema);
- services.AddMvc();
services.AddTransient();
- services.AddSingleton(provider => graphQLEngine);
- services.AddSingleton();
- services.AddSingleton(x =>
- {
- var jsonSerializerSettings = x.GetRequiredService>();
- return new DocumentWriter(Formatting.None, jsonSerializerSettings.Value);
- });
- services.AddTransient(typeof(IGraphQLExecuter<>), typeof(DefaultGraphQLExecuter<>));
- services.AddTransient, WebSocketConnectionFactory>();
- services.AddTransient();
- services.AddTransient();
+
+ // Replace GraphQL Server with GraphQL Convention Document Executer
+ services.Replace(new ServiceDescriptor(typeof(IDocumentExecuter), typeof(DocumentExecuter), ServiceLifetime.Singleton));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
-
- app.UseMvc();
app.UseWebSockets();
- app.UseGraphQLWebSockets();
-
- app.UseGraphQLPlayground(new GraphQLPlaygroundOptions()
+ app.UseRouting();
+ app.UseEndpoints(endpoints =>
{
- Path = "/ui/playground",
- GraphQLEndPoint = "/graphql"
+ endpoints.MapGraphQLWebSockets();
+ endpoints.MapGraphQL();
+ endpoints.MapGraphQLPlayground();
});
}
}
diff --git a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/SubscriptionExample.csproj b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/SubscriptionExample.csproj
index 580affa3..9cc03182 100644
--- a/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/SubscriptionExample.csproj
+++ b/samples/SubscriptionsGraphQLServer/SubscriptionExample/SubscriptionExample/SubscriptionExample.csproj
@@ -1,22 +1,21 @@
- netcoreapp2.2
+ net6.0
InProcess
Linux
753d5ae8-af8c-469c-963e-7c45ef13bd7d
-
-
-
- 7.3
+ 9.0
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/GraphQL.Conventions/Adapters/Engine/DocumentExecuter.cs b/src/GraphQL.Conventions/Adapters/Engine/DocumentExecuter.cs
index 94b80afc..a0a08c94 100644
--- a/src/GraphQL.Conventions/Adapters/Engine/DocumentExecuter.cs
+++ b/src/GraphQL.Conventions/Adapters/Engine/DocumentExecuter.cs
@@ -27,7 +27,7 @@ public async Task ExecuteAsync(ISchema schema, object root, str
.WithRootObject(root)
.WithQueryString(query)
.WithOperationName(operationName)
- .WithInputs(inputs)
+ .WithVariables(inputs)
.WithCancellationToken(cancellationToken)
.WithValidationRules(rules)
.ExecuteAsync();
@@ -41,7 +41,7 @@ public async Task ExecuteAsync(ExecutionOptions options)
.WithRootObject(options.Root)
.WithQueryString(options.Query)
.WithOperationName(options.OperationName)
- .WithInputs(options.Inputs)
+ .WithVariables(options.Variables)
.WithCancellationToken(options.CancellationToken)
.WithValidationRules(options.ValidationRules)
.ExecuteAsync();
diff --git a/src/GraphQL.Conventions/Adapters/Engine/ErrorTransformations/DefaultErrorTransformation.cs b/src/GraphQL.Conventions/Adapters/Engine/ErrorTransformations/DefaultErrorTransformation.cs
index da494765..31a051d1 100644
--- a/src/GraphQL.Conventions/Adapters/Engine/ErrorTransformations/DefaultErrorTransformation.cs
+++ b/src/GraphQL.Conventions/Adapters/Engine/ErrorTransformations/DefaultErrorTransformation.cs
@@ -1,5 +1,6 @@
using System.Linq;
using GraphQL.Conventions.Execution;
+using GraphQLParser;
namespace GraphQL.Conventions.Adapters.Engine.ErrorTransformations
{
@@ -10,9 +11,9 @@ public ExecutionErrors Transform(ExecutionErrors errors)
{
var exception = new FieldResolutionException(executionError);
var error = new ExecutionError(exception.Message, exception);
- foreach (var location in executionError.Locations ?? Enumerable.Empty())
+ foreach (var location in executionError.Locations ?? Enumerable.Empty())
{
- error.AddLocation(location.Line, location.Column);
+ error.AddLocation(location);
}
error.Path = executionError.Path;
result.Add(error);
diff --git a/src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs b/src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs
index 818bad00..02e23078 100644
--- a/src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs
+++ b/src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs
@@ -9,15 +9,16 @@
using GraphQL.Conventions.Adapters.Engine.Listeners.DataLoader;
using GraphQL.Conventions.Builders;
using GraphQL.Conventions.Extensions;
+using GraphQL.Conventions.Relay;
using GraphQL.Conventions.Types.Resolution;
using GraphQL.Execution;
using GraphQL.Instrumentation;
-using GraphQL.Language.AST;
using GraphQL.NewtonsoftJson;
using GraphQL.Types;
using GraphQL.Utilities;
using GraphQL.Validation;
using GraphQL.Validation.Complexity;
+using GraphQLParser.AST;
// ReSharper disable once CheckNamespace
namespace GraphQL.Conventions
@@ -36,7 +37,7 @@ public class GraphQLEngine
private readonly DocumentValidator _documentValidator = new DocumentValidator();
- private readonly DocumentWriter _documentWriter = new DocumentWriter();
+ private readonly GraphQLSerializer _documentSerializer = new GraphQLSerializer();
private SchemaPrinter _schemaPrinter;
@@ -57,15 +58,14 @@ public class GraphQLEngine
private class NoopValidationRule : IValidationRule
{
- public Task ValidateAsync(ValidationContext context)
- => Task.FromResult(new NoopNodeVisitor());
+ public ValueTask ValidateAsync(ValidationContext context) => new(new NoopNodeVisitor());
}
private class NoopNodeVisitor : INodeVisitor
{
- public void Enter(INode node, ValidationContext context) { /* Noop */ }
+ public void Enter(ASTNode node, ValidationContext context) { /* Noop */ }
- public void Leave(INode node, ValidationContext context) { /* Noop */ }
+ public void Leave(ASTNode node, ValidationContext context) { /* Noop */ }
}
private class WrappedDependencyInjector : IDependencyInjector
@@ -270,13 +270,13 @@ public GraphQLEngine RegisterScalarType(string name = null)
return this;
}
- public Task SerializeResultAsync(ExecutionResult result) => _documentWriter.WriteToStringAsync(result);
+ public string SerializeResult(ExecutionResult result) => _documentSerializer.Serialize(result);
internal async Task ExecuteAsync(
object rootObject,
string query,
string operationName,
- Inputs inputs,
+ Inputs variables,
IUserContext userContext,
IDependencyInjector dependencyInjector,
ComplexityConfiguration complexityConfiguration,
@@ -300,7 +300,7 @@ internal async Task ExecuteAsync(
Root = rootObject,
Query = query,
OperationName = operationName,
- Inputs = inputs,
+ Variables = variables,
EnableMetrics = enableProfiling,
UserContext = new Dictionary()
{
@@ -347,7 +347,11 @@ internal async Task ExecuteAsync(
internal async Task ValidateAsync(string queryString)
{
var document = _documentBuilder.Build(queryString);
- var result = await _documentValidator.ValidateAsync(_schema, document, new VariableDefinitions());
+ var result = await _documentValidator.ValidateAsync(new ValidationOptions()
+ {
+ Schema = _schema,
+ Document = document
+ });
return result.validationResult;
}
diff --git a/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs b/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs
index 700d6170..42411125 100644
--- a/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs
+++ b/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs
@@ -49,7 +49,7 @@ public IGraphQLExecutor WithRequest(string requestBody)
var query = _requestDeserializer.GetQueryFromRequestBody(requestBody);
_queryString = query.QueryString;
_operationName = query.OperationName;
- return this.WithInputs(query.Variables);
+ return this.WithVariables(query.Variables);
}
public IGraphQLExecutor WithQueryString(string queryString)
@@ -64,12 +64,12 @@ public IGraphQLExecutor WithOperationName(string operationName)
return this;
}
- public IGraphQLExecutor WithInputs(Dictionary inputs)
+ public IGraphQLExecutor WithVariables(Dictionary inputs)
{
- return WithInputs(new Inputs(inputs ?? new Dictionary()));
+ return WithVariables(new Inputs(inputs ?? new Dictionary()));
}
- public IGraphQLExecutor WithInputs(Inputs inputs)
+ public IGraphQLExecutor WithVariables(Inputs inputs)
{
_inputs = inputs;
return this;
diff --git a/src/GraphQL.Conventions/Adapters/Engine/IGraphQLExecutor.cs b/src/GraphQL.Conventions/Adapters/Engine/IGraphQLExecutor.cs
index 0983f1a5..3f40d12f 100644
--- a/src/GraphQL.Conventions/Adapters/Engine/IGraphQLExecutor.cs
+++ b/src/GraphQL.Conventions/Adapters/Engine/IGraphQLExecutor.cs
@@ -16,9 +16,9 @@ public interface IGraphQLExecutor
IGraphQLExecutor WithOperationName(string operationName);
- IGraphQLExecutor WithInputs(Inputs inputs);
+ IGraphQLExecutor WithVariables(Inputs inputs);
- IGraphQLExecutor WithInputs(Dictionary inputs);
+ IGraphQLExecutor WithVariables(Dictionary inputs);
IGraphQLExecutor WithRootObject(object rootValue);
diff --git a/src/GraphQL.Conventions/Adapters/GraphTypeAdapter.cs b/src/GraphQL.Conventions/Adapters/GraphTypeAdapter.cs
index 71b77db9..971c4513 100644
--- a/src/GraphQL.Conventions/Adapters/GraphTypeAdapter.cs
+++ b/src/GraphQL.Conventions/Adapters/GraphTypeAdapter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using GraphQL.Conventions.Adapters.Resolvers;
using GraphQL.Conventions.Types.Descriptors;
using GraphQL.Conventions.Types.Resolution.Extensions;
using GraphQL.Resolvers;
@@ -85,8 +86,9 @@ private FieldType DeriveField(GraphFieldInfo fieldInfo)
{
if (fieldInfo.Type.IsObservable)
{
- var resolver = new Resolvers.EventStreamResolver(fieldInfo);
- return new EventStreamFieldType
+ var resolver = FieldResolverFactory(fieldInfo);
+ var streamResolver = new EventStreamResolver(resolver);
+ return new FieldType
{
Name = fieldInfo.Name,
Description = fieldInfo.Description,
@@ -94,8 +96,8 @@ private FieldType DeriveField(GraphFieldInfo fieldInfo)
DefaultValue = fieldInfo.DefaultValue,
Type = GetType(fieldInfo.Type),
Arguments = new QueryArguments(fieldInfo.Arguments.Where(arg => !arg.IsInjected).Select(DeriveArgument)),
- Resolver = resolver,
- Subscriber = resolver
+ Resolver = streamResolver,
+ StreamResolver = streamResolver
};
}
return new FieldType
@@ -259,7 +261,7 @@ private IGraphType ConstructEnumerationType(GraphTypeInfo typeInfo)
var graphType = ConstructType(typeof(Types.EnumerationGraphType<>), typeInfo);
foreach (var value in typeInfo.Fields)
{
- graphType.AddValue(value.Name, value.Description, value.Value, value.DeprecationReason);
+ graphType.Add(value.Name, value.Value, value.Description, value.DeprecationReason);
}
return WrapNonNullableType(typeInfo, graphType);
}
diff --git a/src/GraphQL.Conventions/Adapters/ResolutionContext.cs b/src/GraphQL.Conventions/Adapters/ResolutionContext.cs
index d9702c13..b2e962dd 100644
--- a/src/GraphQL.Conventions/Adapters/ResolutionContext.cs
+++ b/src/GraphQL.Conventions/Adapters/ResolutionContext.cs
@@ -12,7 +12,7 @@ public class ResolutionContext : IResolutionContext
{
private static readonly object Lock = new object();
- public ResolutionContext(GraphFieldInfo fieldInfo, ResolveFieldContext