Skip to content

Commit

Permalink
BCP schema endpoint fix (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
rstaib authored and michaelstaib committed Nov 27, 2020
1 parent a9cd72e commit 5faf9aa
Show file tree
Hide file tree
Showing 30 changed files with 78 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ protected override void TryConfigure(

private AuthorizeDirective CreateDirective()
{
if (Policy is { })
if (Policy is not null)
{
return new AuthorizeDirective(
Policy,
apply: Apply);
}
else if (Roles is { })
else if (Roles is not null)
{
return new AuthorizeDirective(
Roles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public AuthorizeDirective(SerializationInfo info, StreamingContext context)
ArgumentNode? resolverArgument = node.Arguments
.FirstOrDefault(t => t.Name.Value == "apply");

Policy = (policyArgument is { }
Policy = (policyArgument is not null
&& policyArgument.Value is StringValueNode sv)
? sv.Value
: null;

if (rolesArgument is { })
if (rolesArgument is not null)
{
if (rolesArgument.Value is ListValueNode lv)
{
Expand All @@ -67,7 +67,7 @@ public AuthorizeDirective(SerializationInfo info, StreamingContext context)
}

Apply = ApplyPolicy.BeforeResolver;
if (resolverArgument is { }
if (resolverArgument is not null
&& resolverArgument.Value.Value is string s
&& s == "AFTER_RESOLVER")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static bool TryGetAuthenticatedPrincipal(
principal = p;
return true;
}

principal = null;
return false;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ private static async Task<AuthState> AuthorizeWithPolicyAsync(
}
}

if (policy is { })
if (policy is not null)
{
AuthorizationResult result =
await authorizeService.AuthorizeAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// Provides GraphQL extensions to the <see cref="IEndpointConventionBuilder"/>.
/// </summary>
public static class HttpEndpointRouteBuilderExtensions
public static class EndpointRouteBuilderExtensions
{
/// <summary>
/// Adds a GraphQL endpoint to the endpoint configurations.
Expand All @@ -35,7 +35,7 @@ public static GraphQLEndpointConventionBuilder MapGraphQL(
this IEndpointRouteBuilder endpointRouteBuilder,
string path = "/graphql",
NameString schemaName = default) =>
MapGraphQL(endpointRouteBuilder, new PathString(path), schemaName);
MapGraphQL(endpointRouteBuilder, new PathString(path), schemaName);

/// <summary>
/// Adds a GraphQL endpoint to the endpoint configurations.
Expand Down Expand Up @@ -137,8 +137,8 @@ public static IApplicationBuilder UseGraphQL(

private static IFileProvider CreateFileProvider()
{
Type type = typeof(HttpEndpointRouteBuilderExtensions);
string resourceNamespace = typeof(MiddlewareBase).Namespace + ".Resources";
var type = typeof(EndpointRouteBuilderExtensions);
var resourceNamespace = typeof(MiddlewareBase).Namespace + ".Resources";

return new EmbeddedFileProvider(type.Assembly, resourceNamespace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace HotChocolate.AspNetCore.Extensions
/// <summary>
/// Represents the endpoint convention builder for GraphQL.
/// </summary>
public sealed class GraphQLEndpointConventionBuilder : IEndpointConventionBuilder
public sealed class GraphQLEndpointConventionBuilder
: IEndpointConventionBuilder
{
private readonly IEndpointConventionBuilder _builder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace HotChocolate.AspNetCore
{
internal static class RequestExecutorExtensions
{
public static T GetRequiredService<T>(
internal static T GetRequiredService<T>(
this IRequestExecutor requestExecutor)
where T : notnull =>
requestExecutor.Services.GetRequiredService<T>();

public static IErrorHandler GetErrorHandler(
internal static IErrorHandler GetErrorHandler(
this IRequestExecutor requestExecutor) =>
requestExecutor.GetRequiredService<IErrorHandler>();

public static IHttpRequestInterceptor GetRequestInterceptor(
internal static IHttpRequestInterceptor GetRequestInterceptor(
this IRequestExecutor requestExecutor) =>
requestExecutor.GetRequiredService<IHttpRequestInterceptor>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ public class GraphQLServerOptions
/// <summary>
/// Defines if GraphQL HTTP GET requests are allowed.
/// </summary>
/// <value></value>
public bool EnableGetRequests { get; set; } = true;

/// <summary>
/// Defines if the GraphQL schema SDL can be downloaded.
/// </summary>
/// <value></value>
public bool EnableSchemaRequests { get; set; } = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"files": {
"static/js/0.1cfbb971.chunk.js": "./static/js/0.1cfbb971.chunk.js",
"static/js/0.98811054.chunk.js": "./static/js/0.98811054.chunk.js",
"static/js/1.2b57407c.chunk.js": "./static/js/1.2b57407c.chunk.js",
"static/js/2.e915aa79.chunk.js": "./static/js/2.e915aa79.chunk.js",
"main.css": "./static/css/main.cc3afb38.chunk.css",
"main.js": "./static/js/main.8e40e632.chunk.js",
"runtime-main.js": "./static/js/runtime-main.addc0bd1.js",
"main.js": "./static/js/main.b6b94305.chunk.js",
"runtime-main.js": "./static/js/runtime-main.f526d4b6.js",
"runtime-schema.worker.js": "./static/js/runtime-schema.worker.620115f9.js",
"schema.worker.js": "./schema.worker.js",
"static/css/7.82f2daa0.chunk.css": "./static/css/7.82f2daa0.chunk.css",
"static/js/7.1b7c0878.chunk.js": "./static/js/7.1b7c0878.chunk.js",
"static/js/8.94e6333b.chunk.js": "./static/js/8.94e6333b.chunk.js",
"static/js/7.742508b3.chunk.js": "./static/js/7.742508b3.chunk.js",
"static/js/8.93da96bd.chunk.js": "./static/js/8.93da96bd.chunk.js",
"static/js/9.142a949c.chunk.js": "./static/js/9.142a949c.chunk.js",
"static/js/10.f8349765.chunk.js": "./static/js/10.f8349765.chunk.js",
"static/js/11.5697221c.chunk.js": "./static/js/11.5697221c.chunk.js",
"static/js/10.3c1131b1.chunk.js": "./static/js/10.3c1131b1.chunk.js",
"static/js/11.4d2e1ed4.chunk.js": "./static/js/11.4d2e1ed4.chunk.js",
"static/js/12.c7d59199.chunk.js": "./static/js/12.c7d59199.chunk.js",
"static/js/13.a15acf04.chunk.js": "./static/js/13.a15acf04.chunk.js",
"static/js/14.9e198614.chunk.js": "./static/js/14.9e198614.chunk.js",
Expand Down Expand Up @@ -78,29 +78,29 @@
"static/js/73.3e67292d.chunk.js": "./static/js/73.3e67292d.chunk.js",
"static/js/74.185c576c.chunk.js": "./static/js/74.185c576c.chunk.js",
"static/js/75.7a374cd6.chunk.js": "./static/js/75.7a374cd6.chunk.js",
"static/js/76.b1db24fb.chunk.js": "./static/js/76.b1db24fb.chunk.js",
"static/js/76.c1d94e40.chunk.js": "./static/js/76.c1d94e40.chunk.js",
"css.worker.js": "./css.worker.js",
"editor.worker.js": "./editor.worker.js",
"html.worker.js": "./html.worker.js",
"index.html": "./index.html",
"json.worker.js": "./json.worker.js",
"precache-manifest.246e6e20cce37623aefa0135a6f27242.js": "./precache-manifest.246e6e20cce37623aefa0135a6f27242.js",
"precache-manifest.435767b328c0106812f6149af451051b.js": "./precache-manifest.435767b328c0106812f6149af451051b.js",
"schema.worker.js.LICENSE.txt": "./schema.worker.js.LICENSE.txt",
"service-worker.js": "./service-worker.js",
"static/js/0.1cfbb971.chunk.js.LICENSE.txt": "./static/js/0.1cfbb971.chunk.js.LICENSE.txt",
"static/js/0.98811054.chunk.js.LICENSE.txt": "./static/js/0.98811054.chunk.js.LICENSE.txt",
"static/js/69.27a7035c.chunk.js.LICENSE.txt": "./static/js/69.27a7035c.chunk.js.LICENSE.txt",
"static/js/7.1b7c0878.chunk.js.LICENSE.txt": "./static/js/7.1b7c0878.chunk.js.LICENSE.txt",
"static/js/8.94e6333b.chunk.js.LICENSE.txt": "./static/js/8.94e6333b.chunk.js.LICENSE.txt",
"static/js/7.742508b3.chunk.js.LICENSE.txt": "./static/js/7.742508b3.chunk.js.LICENSE.txt",
"static/js/8.93da96bd.chunk.js.LICENSE.txt": "./static/js/8.93da96bd.chunk.js.LICENSE.txt",
"static/media/codicon.css": "./static/media/codicon.22349029.ttf",
"ts.worker.js": "./ts.worker.js",
"ts.worker.js.LICENSE.txt": "./ts.worker.js.LICENSE.txt"
},
"entrypoints": [
"static/js/runtime-main.addc0bd1.js",
"static/js/0.1cfbb971.chunk.js",
"static/js/runtime-main.f526d4b6.js",
"static/js/0.98811054.chunk.js",
"static/css/7.82f2daa0.chunk.css",
"static/js/7.1b7c0878.chunk.js",
"static/js/7.742508b3.chunk.js",
"static/css/main.cc3afb38.chunk.css",
"static/js/main.8e40e632.chunk.js"
"static/js/main.b6b94305.chunk.js"
]
}
Loading

0 comments on commit 5faf9aa

Please sign in to comment.