Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GraphQL experimental feature being required #1968

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ 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 }}"
Expand Down
2 changes: 1 addition & 1 deletion build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="WebpanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>6.11.0</TgsCoreVersion>
<TgsCoreVersion>6.11.1</TgsCoreVersion>
<TgsConfigVersion>5.3.0</TgsConfigVersion>
<TgsRestVersion>10.10.0</TgsRestVersion>
<TgsGraphQLVersion>0.2.0</TgsGraphQLVersion>
Expand Down
89 changes: 44 additions & 45 deletions src/Tgstation.Server.Host/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,55 +295,54 @@ void ConfigureNewtonsoftJsonSerializerSettingsForApi(JsonSerializerSettings sett
services.AddSingleton<IAbstractHttpClientFactory, AbstractHttpClientFactory>();

// configure graphql
if (postSetupServices.InternalConfiguration.EnableGraphQL)
services
.AddScoped<GraphQL.Subscriptions.ITopicEventReceiver, ShutdownAwareTopicEventReceiver>()
.AddGraphQLServer()
.AddAuthorization()
.ModifyOptions(options =>
{
options.EnsureAllNodesCanBeResolved = true;
options.EnableFlagEnums = true;
})
services
.AddScoped<GraphQL.Subscriptions.ITopicEventReceiver, ShutdownAwareTopicEventReceiver>()
.AddGraphQLServer()
.AddAuthorization()
.ModifyOptions(options =>
{
options.EnsureAllNodesCanBeResolved = true;
options.EnableFlagEnums = true;
})
#if DEBUG
.ModifyCostOptions(options =>
{
options.EnforceCostLimits = false;
})
.ModifyCostOptions(options =>
{
options.EnforceCostLimits = false;
})
#endif
.AddMutationConventions()
.AddInMemorySubscriptions(
new SubscriptionOptions
{
TopicBufferCapacity = 1024, // mainly so high for tests, not possible to DoS the server without authentication and some other access to generate messages
})
.AddGlobalObjectIdentification()
.AddQueryFieldToMutationPayloads()
.ModifyOptions(options =>
{
options.EnableDefer = true;
})
.ModifyPagingOptions(pagingOptions =>
.AddMutationConventions()
.AddInMemorySubscriptions(
new SubscriptionOptions
{
pagingOptions.IncludeTotalCount = true;
pagingOptions.RequirePagingBoundaries = false;
pagingOptions.DefaultPageSize = ApiController.DefaultPageSize;
pagingOptions.MaxPageSize = ApiController.MaximumPageSize;
TopicBufferCapacity = 1024, // mainly so high for tests, not possible to DoS the server without authentication and some other access to generate messages
})
.AddFiltering()
.AddSorting()
.AddHostTypes()
.AddErrorFilter<ErrorMessageFilter>()
.AddType<StandaloneNode>()
.AddType<LocalGateway>()
.AddType<RemoteGateway>()
.AddType<GraphQL.Types.UserName>()
.AddType<UnsignedIntType>()
.BindRuntimeType<Version, SemverType>()
.TryAddTypeInterceptor<RightsTypeInterceptor>()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>();
.AddGlobalObjectIdentification()
.AddQueryFieldToMutationPayloads()
.ModifyOptions(options =>
{
options.EnableDefer = true;
})
.ModifyPagingOptions(pagingOptions =>
{
pagingOptions.IncludeTotalCount = true;
pagingOptions.RequirePagingBoundaries = false;
pagingOptions.DefaultPageSize = ApiController.DefaultPageSize;
pagingOptions.MaxPageSize = ApiController.MaximumPageSize;
})
.AddFiltering()
.AddSorting()
.AddHostTypes()
.AddErrorFilter<ErrorMessageFilter>()
.AddType<StandaloneNode>()
.AddType<LocalGateway>()
.AddType<RemoteGateway>()
.AddType<GraphQL.Types.UserName>()
.AddType<UnsignedIntType>()
.BindRuntimeType<Version, SemverType>()
.TryAddTypeInterceptor<RightsTypeInterceptor>()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>();

void AddTypedContext<TContext>()
where TContext : DatabaseContext
Expand Down
3 changes: 3 additions & 0 deletions tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public LiveTestingServer(SwarmConfiguration swarmConfiguration, bool enableOAuth
"Telemetry:DisableVersionReporting=true",
};

if (MultiServerClient.UseGraphQL)
args.Add("Internal:EnableGraphQL=true");

swarmArgs = new List<string>();
if (swarmConfiguration != null)
{
Expand Down
9 changes: 7 additions & 2 deletions tests/Tgstation.Server.Tests/Live/MultiServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MultiServerClient(IRestServerClient restServerClient, IGraphQLServerClien
public ValueTask DisposeAsync()
=> ValueTaskExtensions.WhenAll(
RestClient.DisposeAsync(),
GraphQLClient.DisposeAsync());
GraphQLClient?.DisposeAsync() ?? ValueTask.CompletedTask);

public ValueTask Execute(
Func<IRestServerClient, ValueTask> restAction,
Expand All @@ -48,6 +48,11 @@ public ValueTask Execute(
where TGraphQLResult : class
{
var restTask = restAction(RestClient);
if (!UseGraphQL)
{
return (await restTask, null);
}

var graphQLResult = await GraphQLClient.RunOperation(graphQLAction, cancellationToken);

graphQLResult.EnsureNoErrors();
Expand All @@ -60,6 +65,6 @@ public ValueTask Execute(
}

public ValueTask<IDisposable> Subscribe<TResultData>(Func<IGraphQLClient, IObservable<IOperationResult<TResultData>>> operationExecutor, IObserver<IOperationResult<TResultData>> observer, CancellationToken cancellationToken) where TResultData : class
=> GraphQLClient.Subscribe(operationExecutor, observer, cancellationToken);
=> GraphQLClient?.Subscribe(operationExecutor, observer, cancellationToken) ?? ValueTask.FromResult<IDisposable>(new CancellationTokenSource());
}
}
12 changes: 7 additions & 5 deletions tests/Tgstation.Server.Tests/Live/TestLiveServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@
}
}
else
await internalTask;

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (PostgresSql, Basic, Debug)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (PostgresSql, Basic, Release)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (PostgresSql, Advanced, Debug)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (PostgresSql, Advanced, Release)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (MariaDB, Basic, Debug)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (MariaDB, Basic, Release)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (MariaDB, Advanced, Debug)

TestStandardTgsOperation

Assert.IsTrue failed.

Check failure on line 1304 in tests/Tgstation.Server.Tests/Live/TestLiveServer.cs

View workflow job for this annotation

GitHub Actions / CI Pipeline / Linux Live Tests (MariaDB, Advanced, Release)

TestStandardTgsOperation

Assert.IsTrue failed.
}

async Task TestTgsInternal(bool openDreamOnly, CancellationToken hardCancellationToken)
Expand Down Expand Up @@ -1930,11 +1930,13 @@
password,
cancellationToken: cancellationToken);
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
graphQLClientTask = graphQLClientFactory.CreateFromLogin(
url,
username,
password,
cancellationToken: cts.Token);
graphQLClientTask = MultiServerClient.UseGraphQL
? graphQLClientFactory.CreateFromLogin(
url,
username,
password,
cancellationToken: cts.Token)
: ValueTask.FromResult<IAuthenticatedGraphQLServerClient>(null);

IRestServerClient restClient;
try
Expand Down
3 changes: 3 additions & 0 deletions tests/Tgstation.Server.Tests/Live/UsersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ await ValueTaskExtensions.WhenAll(

await TestPagination(cancellationToken);

if (!MultiServerClient.UseGraphQL)
return;

Assert.IsFalse(observer.Completed);
Assert.AreEqual(0U, observer.ErrorCount);

Expand Down
Loading