fallback mechanism

This commit is contained in:
Jedd Morgan
2026-03-24 10:04:44 +00:00
parent 4b319499c3
commit 2b61ab7d2e
2 changed files with 44 additions and 3 deletions
@@ -313,6 +313,37 @@ public sealed class ActiveUserResource
/// <remarks>note this returns a <see cref="LimitedWorkspace"/>, because it may be a workspace the user is not a member of</remarks>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
/// <exception cref="SpeckleException">The ActiveUser could not be found (e.g. the client is not authenticated)</exception>
private async Task<LimitedWorkspace?> GetActiveWorkspace_Legacy(CancellationToken cancellationToken = default)
{
//language=graphql
const string QUERY = """
query ActiveUser {
data:activeUser {
data:activeWorkspace {
id
name
role
slug
description
}
}
}
""";
var request = new GraphQLRequest { Query = QUERY };
var response = await _client
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
.ConfigureAwait(false);
if (response.data is null)
{
throw new SpeckleException("GraphQL response indicated that the ActiveUser could not be found");
}
return response.data.data;
}
public async Task<LimitedWorkspace?> GetActiveWorkspace(CancellationToken cancellationToken = default)
{
//language=graphql
@@ -333,9 +364,18 @@ public sealed class ActiveUserResource
var request = new GraphQLRequest { Query = QUERY };
var response = await _client
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
.ConfigureAwait(false);
NullableResponse<NullableResponse<LimitedWorkspace?>?> response;
try
{
response = await _client
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
.ConfigureAwait(false);
}
catch (SpeckleGraphQLInvalidQueryException)
{
//v2.x.x servers do not have a logoUrl property
return await GetActiveWorkspace_Legacy(cancellationToken).ConfigureAwait(false);
}
if (response.data is null)
{
@@ -76,6 +76,7 @@ public sealed class SubscriptionResource : IDisposable
/// <summary>Subscribe to updates to resource comments/threads. Optionally specify resource ID string to only receive updates regarding comments for those resources</summary>
/// <remarks><inheritdoc cref="CreateUserProjectsUpdatedSubscription"/></remarks>
/// <inheritdoc cref="ISpeckleGraphQLClient.SubscribeTo{T}"/>
[Obsolete("Comments are now issues, and we've not update SDKs with the new subs")]
public Subscription<ProjectCommentsUpdatedMessage> CreateProjectCommentsUpdatedSubscription(
ViewerUpdateTrackingTarget target
)