Skip to content
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

Updates GraphiQL to latest version, uses minified files. #44

Merged
merged 1 commit into from
Mar 11, 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
31 changes: 31 additions & 0 deletions src/GraphiQl/AssetProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;

namespace GraphiQl
{
internal class AssetProvider : IFileProvider
{
private readonly EmbeddedFileProvider _provider;

public AssetProvider(EmbeddedFileProvider provider)
=> _provider = provider;

public IFileInfo GetFileInfo(string subpath)
{
// Embedded resource renames hypphens in directory to underscore, this tells file provider where to find it.
if (subpath.Equals("/es6-promise/es6-promise.min.js", StringComparison.OrdinalIgnoreCase))
{
subpath = "/es6_promise/es6-promise.min.js";
}

return _provider.GetFileInfo(subpath);
}

public IDirectoryContents GetDirectoryContents(string subpath)
=> _provider.GetDirectoryContents(subpath);

public IChangeToken Watch(string filter)
=> _provider.Watch(filter);
}
}
5 changes: 3 additions & 2 deletions src/GraphiQl/GraphiQlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ private static IApplicationBuilder UseGraphiQlImp(this IApplicationBuilder app,
{
if (app == null)
throw new ArgumentNullException(nameof(app));


var provider = new EmbeddedFileProvider(typeof(GraphiQlExtensions).GetTypeInfo().Assembly, "GraphiQl.assets");
var fileServerOptions = new FileServerOptions
{
RequestPath = options.GraphiQlPath,
FileProvider = new EmbeddedFileProvider(typeof(GraphiQlExtensions).GetTypeInfo().Assembly, "GraphiQl.assets"),
FileProvider = new AssetProvider(provider),
EnableDefaultFiles = true,
StaticFileOptions = {ContentTypeProvider = new FileExtensionContentTypeProvider()}
};
Expand Down
Binary file added src/GraphiQl/assets/favicon.ico
Binary file not shown.
Loading