From 23b60b5cb05572376ed47431a4a570ea4a0d1589 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Fri, 28 Feb 2020 13:58:16 +0300 Subject: [PATCH 1/3] upgrade examples --- src/AspNetCore/Example/Example.csproj | 4 ++-- src/AspNetCore/Example/Startup.cs | 7 ++++--- src/AspNetCoreCustom/Example/Example.csproj | 3 ++- src/AspNetCoreCustom/Example/GraphQLMiddleware.cs | 2 +- src/AspNetCoreCustom/Example/Startup.cs | 3 +-- src/AspNetWebApi/WebApi/Bootstrapper.cs | 3 +-- .../WebApi/Controllers/GraphQLController.cs | 2 +- src/AspNetWebApi/WebApi/Web.config | 6 +++++- src/AspNetWebApi/WebApi/WebApi.csproj | 12 +++++++++--- src/AspNetWebApi/WebApi/packages.config | 9 +++++---- src/StarWars/StarWars.csproj | 2 +- src/StarWars/StarWarsMutation.cs | 1 + src/StarWars/StarWarsQuery.cs | 3 ++- 13 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/AspNetCore/Example/Example.csproj b/src/AspNetCore/Example/Example.csproj index d7648c4..e32ec9b 100644 --- a/src/AspNetCore/Example/Example.csproj +++ b/src/AspNetCore/Example/Example.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/AspNetCore/Example/Startup.cs b/src/AspNetCore/Example/Startup.cs index 587594e..0fccedf 100644 --- a/src/AspNetCore/Example/Startup.cs +++ b/src/AspNetCore/Example/Startup.cs @@ -26,11 +26,12 @@ public void ConfigureServices(IServiceCollection services) services.AddLogging(builder => builder.AddConsole()); services.AddHttpContextAccessor(); - services.AddGraphQL(_ => + services.AddGraphQL(options => { - _.EnableMetrics = true; - _.ExposeExceptions = true; + options.EnableMetrics = true; + options.ExposeExceptions = true; }) + .AddNewtonsoftJson() // or use AddSystemTextJson for .NET Core 3+ .AddUserContextBuilder(httpContext => new GraphQLUserContext { User = httpContext.User }); } diff --git a/src/AspNetCoreCustom/Example/Example.csproj b/src/AspNetCoreCustom/Example/Example.csproj index 5b2f5a6..c7a905b 100644 --- a/src/AspNetCoreCustom/Example/Example.csproj +++ b/src/AspNetCoreCustom/Example/Example.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.2 @@ -7,6 +7,7 @@ + diff --git a/src/AspNetCoreCustom/Example/GraphQLMiddleware.cs b/src/AspNetCoreCustom/Example/GraphQLMiddleware.cs index 5542e4b..36c65a9 100644 --- a/src/AspNetCoreCustom/Example/GraphQLMiddleware.cs +++ b/src/AspNetCoreCustom/Example/GraphQLMiddleware.cs @@ -1,6 +1,6 @@ using GraphQL; -using GraphQL.Http; using GraphQL.Instrumentation; +using GraphQL.NewtonsoftJson; using GraphQL.Types; using GraphQL.Validation; using Microsoft.AspNetCore.Http; diff --git a/src/AspNetCoreCustom/Example/Startup.cs b/src/AspNetCoreCustom/Example/Startup.cs index aa79ea3..a609748 100644 --- a/src/AspNetCoreCustom/Example/Startup.cs +++ b/src/AspNetCoreCustom/Example/Startup.cs @@ -1,5 +1,4 @@ using GraphQL; -using GraphQL.Http; using GraphQL.Types; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -15,7 +14,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/src/AspNetWebApi/WebApi/Bootstrapper.cs b/src/AspNetWebApi/WebApi/Bootstrapper.cs index 33af37a..9902718 100644 --- a/src/AspNetWebApi/WebApi/Bootstrapper.cs +++ b/src/AspNetWebApi/WebApi/Bootstrapper.cs @@ -1,5 +1,4 @@ using GraphQL; -using GraphQL.Http; using GraphQL.Types; using IoC; using StarWars; @@ -20,7 +19,7 @@ private ISimpleContainer BuildContainer() { var container = new SimpleContainer(); container.Singleton(new DocumentExecuter()); - container.Singleton(new DocumentWriter(true)); + container.Singleton(new GraphQL.NewtonsoftJson.DocumentWriter(true)); container.Singleton(new StarWarsData()); container.Register(); diff --git a/src/AspNetWebApi/WebApi/Controllers/GraphQLController.cs b/src/AspNetWebApi/WebApi/Controllers/GraphQLController.cs index b92a691..79a4a99 100644 --- a/src/AspNetWebApi/WebApi/Controllers/GraphQLController.cs +++ b/src/AspNetWebApi/WebApi/Controllers/GraphQLController.cs @@ -1,7 +1,7 @@ -using GraphQL.Http; using GraphQL.Instrumentation; using GraphQL.Types; using GraphQL.Validation.Complexity; +using GraphQL.NewtonsoftJson; using System.Net; using System.Net.Http; using System.Text; diff --git a/src/AspNetWebApi/WebApi/Web.config b/src/AspNetWebApi/WebApi/Web.config index 032e30e..090b7c5 100644 --- a/src/AspNetWebApi/WebApi/Web.config +++ b/src/AspNetWebApi/WebApi/Web.config @@ -1,4 +1,4 @@ - + - - - - + + + + - - + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AspNetWebApi/WebApi/WebApi.csproj b/src/AspNetWebApi/WebApi/WebApi.csproj index b3316e8..d1ee2c8 100644 --- a/src/AspNetWebApi/WebApi/WebApi.csproj +++ b/src/AspNetWebApi/WebApi/WebApi.csproj @@ -1,4 +1,4 @@ - + @@ -48,18 +48,18 @@ ..\packages\GraphQL.3.0.0-preview-1558\lib\netstandard2.0\GraphQL.dll - - ..\packages\GraphQL.NewtonsoftJson.3.0.0-preview-1558\lib\netstandard2.0\GraphQL.dll - - + ..\packages\GraphQL-Parser.5.0.1\lib\netstandard2.0\GraphQL-Parser.dll + + ..\packages\GraphQL.NewtonsoftJson.3.0.0-preview-1558\lib\netstandard2.0\GraphQL.NewtonsoftJson.dll + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll @@ -237,4 +237,4 @@ --> - + \ No newline at end of file diff --git a/src/AspNetWebApi/WebApi/packages.config b/src/AspNetWebApi/WebApi/packages.config index 645b7db..0a242f7 100644 --- a/src/AspNetWebApi/WebApi/packages.config +++ b/src/AspNetWebApi/WebApi/packages.config @@ -1,4 +1,4 @@ - + @@ -16,7 +16,7 @@ - + @@ -27,4 +27,4 @@ - + \ No newline at end of file diff --git a/src/AzureFunctions/Example/Example.csproj b/src/AzureFunctions/Example/Example.csproj index dc5da09..4edd705 100644 --- a/src/AzureFunctions/Example/Example.csproj +++ b/src/AzureFunctions/Example/Example.csproj @@ -5,7 +5,8 @@ enable - + + diff --git a/src/AzureFunctions/Example/GraphQLExecuterExtensions.cs b/src/AzureFunctions/Example/GraphQLExecuterExtensions.cs index 2259ae7..2c2d9a6 100644 --- a/src/AzureFunctions/Example/GraphQLExecuterExtensions.cs +++ b/src/AzureFunctions/Example/GraphQLExecuterExtensions.cs @@ -3,6 +3,7 @@ // // https://github.com/tpeczek using GraphQL; +using GraphQL.NewtonsoftJson; using GraphQL.Server.Internal; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -49,7 +50,7 @@ public async static Task ExecuteAsync(this IGraphQLExecuter gra break; case GRAPHQL_MEDIA_TYPE: query = await ExtractGraphQLQueryFromGraphQLBodyAsync(request.Body); - variables = new Inputs(); + variables = Inputs.Empty; break; case FORM_URLENCODED_MEDIA_TYPE: (operationName, query, variables) = await ExtractGraphQLAttributesFromFormCollectionAsync(request); @@ -77,7 +78,7 @@ private static (string? operationName, string query, Inputs variables) ExtractGr return ( request.Query.TryGetValue(OPERATION_NAME_KEY, out var operationNameValues) ? operationNameValues[0] : null, request.Query[QUERY_KEY][0], - request.Query.TryGetValue(VARIABLES_KEY, out var variablesValues) ? variablesValues[0].ToInputs() : new Inputs() + request.Query.TryGetValue(VARIABLES_KEY, out var variablesValues) ? variablesValues[0].ToInputs() : Inputs.Empty ); } diff --git a/src/AzureFunctions/Example/GraphQLExecutionResult.cs b/src/AzureFunctions/Example/GraphQLExecutionResult.cs index 91b67db..73f59fb 100644 --- a/src/AzureFunctions/Example/GraphQLExecutionResult.cs +++ b/src/AzureFunctions/Example/GraphQLExecutionResult.cs @@ -3,7 +3,6 @@ // // https://github.com/tpeczek using GraphQL; -using GraphQL.Http; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; diff --git a/src/AzureFunctions/nuget.config b/src/AzureFunctions/nuget.config new file mode 100644 index 0000000..2c0eb01 --- /dev/null +++ b/src/AzureFunctions/nuget.config @@ -0,0 +1,6 @@ + + + + + +