Skip to content

Upgrade examples #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/AspNetCore/Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="3.5.0-alpha0041" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="3.5.0-alpha0041" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore.NewtonsoftJson" Version="3.5.0-alpha0060" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="3.5.0-alpha0060" />
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>

Expand Down
7 changes: 4 additions & 3 deletions src/AspNetCore/Example/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down
3 changes: 2 additions & 1 deletion src/AspNetCoreCustom/Example/Example.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
Expand All @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL.Server.Transports.AspNetCore.NewtonsoftJson" Version="3.5.0-alpha0060" />
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreCustom/Example/GraphQLMiddleware.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/AspNetCoreCustom/Example/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using GraphQL;
using GraphQL.Http;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -15,7 +14,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
services.AddSingleton<IDocumentWriter, DocumentWriter>();
services.AddSingleton<IDocumentWriter, GraphQL.NewtonsoftJson.DocumentWriter>();

services.AddSingleton<StarWarsData>();
services.AddSingleton<StarWarsQuery>();
Expand Down
3 changes: 1 addition & 2 deletions src/AspNetWebApi/WebApi/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using GraphQL;
using GraphQL.Http;
using GraphQL.Types;
using IoC;
using StarWars;
Expand All @@ -20,7 +19,7 @@ private ISimpleContainer BuildContainer()
{
var container = new SimpleContainer();
container.Singleton<IDocumentExecuter>(new DocumentExecuter());
container.Singleton<IDocumentWriter>(new DocumentWriter(true));
container.Singleton<IDocumentWriter>(new GraphQL.NewtonsoftJson.DocumentWriter(true));

container.Singleton(new StarWarsData());
container.Register<StarWarsQuery>();
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetWebApi/WebApi/Controllers/GraphQLController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using GraphQL.Http;
using GraphQL.Instrumentation;
using GraphQL.NewtonsoftJson;
using GraphQL.Types;
using GraphQL.Validation.Complexity;
using System.Net;
Expand Down
532 changes: 256 additions & 276 deletions src/AspNetWebApi/WebApi/Web.config

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions src/AspNetWebApi/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Expand Down Expand Up @@ -45,18 +45,21 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GraphQL, Version=3.0.0.1357, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GraphQL.3.0.0-preview-1357\lib\netstandard2.0\GraphQL.dll</HintPath>
<Reference Include="GraphQL, Version=3.0.0.1558, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GraphQL.3.0.0-preview-1558\lib\netstandard2.0\GraphQL.dll</HintPath>
</Reference>
<Reference Include="GraphQL-Parser, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GraphQL-Parser.4.2.0\lib\netstandard2.0\GraphQL-Parser.dll</HintPath>
<Reference Include="GraphQL-Parser, Version=5.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GraphQL-Parser.5.0.1\lib\netstandard2.0\GraphQL-Parser.dll</HintPath>
</Reference>
<Reference Include="GraphQL.NewtonsoftJson, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GraphQL.NewtonsoftJson.3.0.0-preview-1558\lib\netstandard2.0\GraphQL.NewtonsoftJson.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
Expand Down Expand Up @@ -234,4 +237,4 @@
</Target>
<Target Name="AfterBuild">
</Target> -->
</Project>
</Project>
7 changes: 4 additions & 3 deletions src/AspNetWebApi/WebApi/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net461" />
<package id="GraphQL" version="3.0.0-preview-1282" targetFramework="net461" />
<package id="GraphQL-Parser" version="4.1.1" targetFramework="net461" />
<package id="GraphQL" version="3.0.0-preview-1558" targetFramework="net461" />
<package id="GraphQL.NewtonsoftJson" version="3.0.0-preview-1558" targetFramework="net461" />
<package id="GraphQL-Parser" version="5.0.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net461" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net461" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
Expand All @@ -15,7 +16,7 @@
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net461" />
<package id="Microsoft.CSharp" version="4.5.0" targetFramework="net461" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="System.Buffers" version="4.5.0" targetFramework="net461" />
<package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net461" />
<package id="System.Reactive" version="4.1.6" targetFramework="net461" />
Expand Down
3 changes: 2 additions & 1 deletion src/AzureFunctions/Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphQL.Server.Core" Version="3.5.0-alpha0027" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="3.0.0-preview-1558" />
<PackageReference Include="GraphQL.Server.Core" Version="3.5.0-alpha0060" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/AzureFunctions/Example/GraphQLExecuterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// </copyright>
// <author>https://github.com/tpeczek</author>
using GraphQL;
using GraphQL.NewtonsoftJson;
using GraphQL.Server.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -49,7 +50,7 @@ public async static Task<ExecutionResult> 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);
Expand Down Expand Up @@ -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
);
}

Expand Down
1 change: 0 additions & 1 deletion src/AzureFunctions/Example/GraphQLExecutionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// </copyright>
// <author>https://github.com/tpeczek</author>
using GraphQL;
using GraphQL.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
Expand Down
6 changes: 6 additions & 0 deletions src/AzureFunctions/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="myget-graphql-dotnet" value="https://myget.org/F/graphql-dotnet/api/v3/index.json" />
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion src/StarWars/StarWars.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL" Version="3.0.0-preview-1357" />
<PackageReference Include="GraphQL" Version="3.0.0-preview-1558" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/StarWars/StarWarsMutation.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GraphQL;
using GraphQL.Types;
using StarWars.Types;

Expand Down
3 changes: 2 additions & 1 deletion src/StarWars/StarWarsQuery.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using GraphQL;
using GraphQL.Types;
using StarWars.Types;

Expand All @@ -19,7 +20,7 @@ public StarWarsQuery(StarWarsData data)
resolve: context => data.GetHumanByIdAsync(context.GetArgument<string>("id"))
);

Func<ResolveFieldContext, string, object> func = (context, id) => data.GetDroidByIdAsync(id);
Func<IResolveFieldContext, string, object> func = (context, id) => data.GetDroidByIdAsync(id);

FieldDelegate<DroidType>(
"droid",
Expand Down