Skip to content

Commit

Permalink
Added support to disable subscription on UseGraphQL (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Aug 14, 2019
1 parent 517aae4 commit 56997bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/Server/AspNetCore.Abstractions/QueryMiddlewareOptions.cs
Expand Up @@ -21,9 +21,7 @@ public class QueryMiddlewareOptions
private PathString _subscriptionPath = new PathString("/");
private ParserOptions _parserOptions = new ParserOptions();

[Obsolete(
"Use query execution options.",
true)]
[Obsolete("Use query execution options.", true)]
public int QueryCacheSize { get; set; } = 100;

public int MaxRequestSize { get; set; } = 20 * 1000 * 1000;
Expand All @@ -40,6 +38,7 @@ public ParserOptions ParserOptions
_parserOptions = value;
}
}

public PathString Path
{
get => _path;
Expand Down Expand Up @@ -73,6 +72,10 @@ public PathString SubscriptionPath
}
}

#if !ASPNETCLASSIC
public bool EnableSubscriptions { get; set; } = true;
#endif

[Obsolete(
"Use serviceCollection.AddSocketConnectionInterceptor()",
true)]
Expand Down
19 changes: 13 additions & 6 deletions src/Server/AspNetCore/Extensions/ApplicationBuilderExtensions.cs
Expand Up @@ -41,7 +41,7 @@ public static class ApplicationBuilderExtensions
throw new ArgumentNullException(nameof(options));
}

return applicationBuilder
applicationBuilder
.UseGraphQLHttpPost(new HttpPostMiddlewareOptions
{
Path = options.Path,
Expand All @@ -55,12 +55,19 @@ public static class ApplicationBuilderExtensions
.UseGraphQLHttpGetSchema(new HttpGetSchemaMiddlewareOptions
{
Path = options.Path.Add(new PathString("/schema"))
})
.UseGraphQLSubscriptions(new SubscriptionMiddlewareOptions
{
ParserOptions = options.ParserOptions,
Path = options.SubscriptionPath
});

if (options.EnableSubscriptions)
{
applicationBuilder.UseGraphQLSubscriptions(
new SubscriptionMiddlewareOptions
{
ParserOptions = options.ParserOptions,
Path = options.SubscriptionPath
});
}

return applicationBuilder;
}
}
}

0 comments on commit 56997bb

Please sign in to comment.