예제 #1
0
        private static IAppBuilder UseGraphiQl(this IAppBuilder app, Func <GraphQlOptions, GraphQlOptions> config)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var assembly = typeof(GraphiQlExtensions).GetTypeInfo().Assembly;

            var path = "/graphql";

            path = path.StartsWith("/") ? path : "/" + path;

            var graphQlOptions = new GraphQlOptions
            {
                Path = new PathString(path)
            };

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                RequestPath        = config(graphQlOptions).Path,
                FileSystem         = new EmbeddedResourceFileSystem(assembly, "GraphiQL.assets"),
                StaticFileOptions  = { ContentTypeProvider = new FileExtensionContentTypeProvider() },
            };

            app.UseFileServer(options);

            return(app);
        }
예제 #2
0
 internal static GraphQlOptions Bootstrap(GraphQlOptions options)
 {
     return(new GraphiQlConfig(options).Options);
 }
예제 #3
0
 private GraphiQlConfig(GraphQlOptions options)
 {
     Options = options;
 }