mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-18 03:23:07 +01:00
Allow GraphQL to be worked on in dev by hiding it behind an internal parameter
This commit is contained in:
@@ -40,6 +40,7 @@ env:
|
||||
TGS_WEBPANEL_NODE_VERSION: 20.x
|
||||
TGS_TEST_GITHUB_TOKEN: ${{ secrets.LIVE_TESTS_TOKEN }}
|
||||
PACKAGING_PRIVATE_KEY_PASSPHRASE: ${{ secrets.PACKAGING_PRIVATE_KEY_PASSPHRASE }}
|
||||
Internal__EnableGraphQL: true
|
||||
|
||||
concurrency:
|
||||
group: "ci-${{ (github.event_name != 'push' && github.event_name != 'schedule' && github.event.inputs.pull_request_number) || github.run_id }}-${{ github.event_name }}"
|
||||
|
||||
@@ -35,6 +35,16 @@
|
||||
/// </summary>
|
||||
public string? DumpGraphQLApiPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables hosting the experimental GraphQL API in Release builds.
|
||||
/// </summary>
|
||||
public bool EnableGraphQL
|
||||
#if DEBUG
|
||||
=> true;
|
||||
#else
|
||||
{ get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The base path for the app settings configuration files.
|
||||
/// </summary>
|
||||
|
||||
@@ -288,12 +288,13 @@ namespace Tgstation.Server.Host.Core
|
||||
services.AddSingleton<IAbstractHttpClientFactory, AbstractHttpClientFactory>();
|
||||
|
||||
// configure graphql
|
||||
services
|
||||
.AddGraphQLServer()
|
||||
.AddAuthorization()
|
||||
.AddType<UnsignedIntType>()
|
||||
.BindRuntimeType<Version, SemverType>()
|
||||
.AddQueryType<Query>();
|
||||
if (postSetupServices.InternalConfiguration.EnableGraphQL)
|
||||
services
|
||||
.AddGraphQLServer()
|
||||
.AddAuthorization()
|
||||
.AddType<UnsignedIntType>()
|
||||
.BindRuntimeType<Version, SemverType>()
|
||||
.AddQueryType<Query>();
|
||||
|
||||
void AddTypedContext<TContext>()
|
||||
where TContext : DatabaseContext
|
||||
@@ -466,6 +467,7 @@ namespace Tgstation.Server.Host.Core
|
||||
/// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the <see cref="ControlPanelConfiguration"/> to use.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the <see cref="GeneralConfiguration"/> to use.</param>
|
||||
/// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the <see cref="SwarmConfiguration"/> to use.</param>
|
||||
/// <param name="internalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the <see cref="InternalConfiguration"/> to use.</param>
|
||||
/// <param name="logger">The <see cref="Microsoft.Extensions.Logging.ILogger"/> for the <see cref="Application"/>.</param>
|
||||
public void Configure(
|
||||
IApplicationBuilder applicationBuilder,
|
||||
@@ -476,6 +478,7 @@ namespace Tgstation.Server.Host.Core
|
||||
IOptions<ControlPanelConfiguration> controlPanelConfigurationOptions,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SwarmConfiguration> swarmConfigurationOptions,
|
||||
IOptions<InternalConfiguration> internalConfigurationOptions,
|
||||
ILogger<Application> logger)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(applicationBuilder);
|
||||
@@ -489,6 +492,7 @@ namespace Tgstation.Server.Host.Core
|
||||
var controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions));
|
||||
var generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
var swarmConfiguration = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
|
||||
var internalConfiguration = internalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(internalConfigurationOptions));
|
||||
|
||||
ArgumentNullException.ThrowIfNull(logger);
|
||||
|
||||
@@ -609,7 +613,11 @@ namespace Tgstation.Server.Host.Core
|
||||
// majority of handling is done in the controllers
|
||||
endpoints.MapControllers();
|
||||
|
||||
endpoints.MapGraphQL(Routes.GraphQL);
|
||||
if (internalConfiguration.EnableGraphQL)
|
||||
{
|
||||
logger.LogWarning("Enabling GraphQL. This API is experimental and breaking changes may occur at any time!");
|
||||
endpoints.MapGraphQL(Routes.GraphQL);
|
||||
}
|
||||
});
|
||||
|
||||
// 404 anything that gets this far
|
||||
|
||||
Reference in New Issue
Block a user