Skip to content

Commit

Permalink
Update UI (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwoodward authored Mar 11, 2020
1 parent 27d03c8 commit 88e1813
Show file tree
Hide file tree
Showing 9 changed files with 390 additions and 38,880 deletions.
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

0 comments on commit 88e1813

Please sign in to comment.