-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,166 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
language: csharp | ||
dotnet: 3.1 | ||
mono: none | ||
solution: GraphQL.Tool.Embedded.sln | ||
branches: | ||
only: | ||
- main | ||
before_script: | ||
- dotnet restore | ||
script: | ||
- dotnet build | ||
before_deploy: | ||
- git checkout origin/main && git fetch && git remote set-url origin https://${GITHUB_OAUTH_TOKEN}@github.com/ZEXSM/GraphQL.Tool.Embedded.git | ||
- PR_TITLE=$(git log -1 --pretty='%f') | ||
- LAST_TAG=$(echo $(git describe --tags $(git rev-list --tags --max-count=1)) | cut -d'v' -f 2) | ||
- CURRENT_MAJOR=$(echo $LAST_TAG | cut -d. -f 1) | ||
- CURRENT_MINOR=$(echo $LAST_TAG | cut -d. -f 2) | ||
- CURRENT_PATCH=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 1) | ||
- RC=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 2) | ||
- MAJOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MAJOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo $(($CURRENT_MAJOR+1))) || echo $CURRENT_MAJOR) | ||
- MINOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MINOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo $(($CURRENT_MINOR+1))) || echo $CURRENT_MINOR) | ||
- PATCH=$(([ "$RC" == "rc" ] && echo $CURRENT_PATCH) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo 0) || echo $(($CURRENT_PATCH+1))) | ||
- NEW_TAG=$(echo $MAJOR.$MINOR.$PATCH) | ||
- PACKAGE_VERSION=${NEW_TAG:-$DEFAULT_PACKAGE_VERSION} | ||
- git tag v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION | ||
- dotnet pack -c $CONFIGURATION -p:PackageVersion=$PACKAGE_VERSION | ||
deploy: | ||
provider: releases | ||
name: v$PACKAGE_VERSION | ||
token: $GITHUB_OAUTH_TOKEN | ||
cleanup: true | ||
repo: ZEXSM/GraphQL.Tool.Embedded | ||
on: | ||
branch: main | ||
after_deploy: | ||
- dotnet nuget push ./src/GraphQL.Tool.Embedded/bin/Release/GraphQL.Tool.Embedded.$PACKAGE_VERSION.nupkg -k $NUGET_API_KEY -s $NUGET_SOURCE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31605.320 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{811390A2-7C82-4B98-8ADF-8D6CC71A664F}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{3E1286D4-8304-4487-8529-93ACE3B8BC01}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
.travis.yml = .travis.yml | ||
LICENSE = LICENSE | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Tool.Embedded", "src\GraphQL.Tool.Embedded\GraphQL.Tool.Embedded.csproj", "{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{ADD06312-F49E-4139-A83C-084E79060BAC}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Server", "example\GraphQL.Server\GraphQL.Server.csproj", "{D4CDF859-E269-4335-A65F-EAD41250B095}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D4CDF859-E269-4335-A65F-EAD41250B095}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D4CDF859-E269-4335-A65F-EAD41250B095}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D4CDF859-E269-4335-A65F-EAD41250B095}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D4CDF859-E269-4335-A65F-EAD41250B095}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{2FD01E5E-EE7A-44EF-BC2D-E159DE0AED2F} = {811390A2-7C82-4B98-8ADF-8D6CC71A664F} | ||
{D4CDF859-E269-4335-A65F-EAD41250B095} = {ADD06312-F49E-4139-A83C-084E79060BAC} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {CD284B87-34C6-439F-8E23-65A2EB9DE9F2} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# GraphQL.Playground | ||
# GraphQL.Tool.Embedded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace GraphQL.Server | ||
{ | ||
public class Author | ||
{ | ||
public string Name { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace GraphQL.Server | ||
{ | ||
public class Book | ||
{ | ||
public string Title { get; set; } | ||
|
||
public Author Author { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="HotChocolate.AspNetCore" Version="12.0.0-rc.9" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\GraphQL.Tool.Embedded\GraphQL.Tool.Embedded.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace GraphQL.Server | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"GraphQL.Server": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": "true", | ||
"launchBrowser": true, | ||
"launchUrl": "graphql/playground", | ||
"applicationUrl": "http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace GraphQL.Server | ||
{ | ||
public class Query | ||
{ | ||
public Book GetBook() => | ||
new Book | ||
{ | ||
Title = "C# in depth.", | ||
Author = new Author | ||
{ | ||
Name = "Jon Skeet" | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace GraphQL.Server | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services | ||
.AddGraphQLServer() | ||
.AddQueryType<Query>(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | ||
{ | ||
app.UseRouting(); | ||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapGraphQLHttp(); | ||
endpoints.MapGraphQLSchema(); | ||
|
||
endpoints.MapGraphQLPlayground(); | ||
endpoints.MapGraphQLVoyager(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Information", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
63 changes: 63 additions & 0 deletions
63
src/GraphQL.Tool.Embedded/Extensions/EndpointRouteBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using GraphQL.Tool.Embedded; | ||
using GraphQL.Tool.Embedded.Playground; | ||
using GraphQL.Tool.Embedded.Voyager; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using System; | ||
|
||
namespace Microsoft.AspNetCore.Builder | ||
{ | ||
public static class EndpointRouteBuilderExtensions | ||
{ | ||
public static IEndpointRouteBuilder MapGraphQLPlayground( | ||
this IEndpointRouteBuilder endpoints, | ||
string requestPath = "/graphql/playground", | ||
PlaygroundOptions options = default) | ||
{ | ||
if (endpoints == null) | ||
{ | ||
throw new ArgumentNullException(nameof(endpoints)); | ||
} | ||
|
||
var playgroundPage = new PlaygroundPage(requestPath, options ?? new PlaygroundOptions()); | ||
|
||
var staticFileMiddleware = new StaticFileMiddleware(playgroundPage); | ||
var playgroundMiddleware = new PlaygroundMiddleware(playgroundPage); | ||
|
||
endpoints | ||
.MapStaticFile(playgroundPage.AssetsPath, staticFileMiddleware.Invoke) | ||
.MapGet(requestPath, playgroundMiddleware.Invoke); | ||
|
||
return endpoints; | ||
} | ||
|
||
public static IEndpointRouteBuilder MapGraphQLVoyager( | ||
this IEndpointRouteBuilder endpoints, | ||
string requestPath = "/graphql/voyager", | ||
VoyagerOptions options = default) | ||
{ | ||
if (endpoints == null) | ||
{ | ||
throw new ArgumentNullException(nameof(endpoints)); | ||
} | ||
|
||
var voyagerPage = new VoyagerPage(requestPath, options ?? new VoyagerOptions()); | ||
|
||
var staticFileMiddleware = new StaticFileMiddleware(voyagerPage); | ||
var voyagerMiddleware = new VoyagerMiddleware(voyagerPage); | ||
|
||
endpoints | ||
.MapStaticFile(voyagerPage.AssetsPath, staticFileMiddleware.Invoke) | ||
.MapGet(requestPath, voyagerMiddleware.Invoke); | ||
|
||
return endpoints; | ||
} | ||
|
||
private static IEndpointRouteBuilder MapStaticFile(this IEndpointRouteBuilder endpoints, string requestPath, RequestDelegate requestDelegate) | ||
{ | ||
endpoints.MapGet($"{requestPath}/{{*path:file}}", requestDelegate); | ||
|
||
return endpoints; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<PackageId>GraphQL.Tool.Embedded</PackageId> | ||
<PackageVersion>$(PackageVersion)</PackageVersion> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||
<PackageProjectUrl>https://github.com/ZEXSM/GraphQL.Tool.Embedded</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/ZEXSM/GraphQL.Tool.Embedded</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageTags>graphql;graphql-playground;graphql-voyager</PackageTags> | ||
<Authors>ZEXSM</Authors> | ||
<Description>Library of GraphQL tools such as GraphQL Playground and GraphQL Voyager.</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Playground\index.html" /> | ||
<EmbeddedResource Include="Voyager\index.html" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Playground\Assets\*" /> | ||
<EmbeddedResource Include="Voyager\Assets\*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions
125
src/GraphQL.Tool.Embedded/Playground/Assets/middleware.js
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/GraphQL.Tool.Embedded/Playground/PlaygroundMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace GraphQL.Tool.Embedded.Playground | ||
{ | ||
internal class PlaygroundMiddleware : ToolMiddleware | ||
{ | ||
public PlaygroundMiddleware(PlaygroundPage playgroundPage) | ||
: base(playgroundPage) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.