From 2c6087cd8f74e941fb92c1ae11aa64e99839f471 Mon Sep 17 00:00:00 2001
From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com>
Date: Mon, 8 Jul 2024 16:44:05 +0100
Subject: [PATCH 1/2] feat(Core): [CNX-7561] - GraphQL Client functions for new
FE2 API (#3155)
* First pass for resource implementation
* parking for now
* API tests
* Deprecated legacy API functions
* subscriptions
* Deprecation of old
* Tests
* Removed generic args from graphql exception types
* Fixed tests
* More tests
* More tests passing
* Project Invites now done!
* Version tests
* Fix warnings
* fixed integration tests
* polish
* removed unused using statements
* xml doc
* removed commented out properties
* removed todo comments
* more pr comments resolved
* server limits
* int enum as int
* Fixed accidental negation of execution success
* subscriptions
* csharpier
* subscription queries
* using directive
---
.../Speckle.Automate.Sdk/AutomationContext.cs | 1 +
.../Speckle.Automate.Sdk.csproj | 2 +-
Core/Core/Api/Exceptions.cs | 97 +++--
.../Client.ObsoleteOperations.cs | 250 -------------
.../Client.UserOperations.cs | 99 -----
Core/Core/Api/GraphQL/Client.cs | 243 ++++++------
.../Enums/FileUploadConversionStatus.cs | 10 +
.../ProjectCommentsUpdatedMessageType.cs | 8 +
.../ProjectFileImportUpdatedMessageType.cs | 7 +
.../Enums/ProjectModelsUpdatedMessageType.cs | 8 +
.../ProjectPendingModelsUpdatedMessageType.cs | 7 +
.../Enums/ProjectUpdatedMessageType.cs | 7 +
.../ProjectVersionsUpdatedMessageType.cs | 8 +
.../Api/GraphQL/Enums/ProjectVisibility.cs | 8 +
Core/Core/Api/GraphQL/Enums/ResourceType.cs | 9 +
.../Enums/UserProjectsUpdatedMessageType.cs | 7 +
.../GraphQL/GraphQLHttpClientExtensions.cs | 4 +-
.../Core/Api/GraphQL/ISpeckleGraphQLClient.cs | 20 +
Core/Core/Api/GraphQL/Inputs/CommentInputs.cs | 17 +
Core/Core/Api/GraphQL/Inputs/ModelInputs.cs | 11 +
Core/Core/Api/GraphQL/Inputs/ProjectInputs.cs | 39 ++
.../Api/GraphQL/Inputs/SubscriptionInputs.cs | 7 +
Core/Core/Api/GraphQL/Inputs/VersionInputs.cs | 9 +
.../Client.ActivityOperations.cs | 3 +-
.../Client.BranchOperations.cs | 20 +
.../Client.CommentOperations.cs | 6 +
.../Client.CommitOperations.cs | 14 +
.../Client.ObjectOperations.cs | 1 +
.../Client.ServerOperations.cs | 1 +
.../Client.StreamOperations.cs | 42 ++-
.../Client.UserOperations.cs | 54 +++
.../Client.Subscriptions.Branch.cs | 0
.../Client.Subscriptions.Commit.cs | 0
.../Client.Subscriptions.Stream.cs | 0
.../LegacyGraphQLModels.cs} | 276 +++-----------
Core/Core/Api/GraphQL/Legacy/Manager.cs | 98 +++++
.../{ => Legacy}/SubscriptionModels.cs | 12 +
Core/Core/Api/GraphQL/Models/Collections.cs | 19 +
Core/Core/Api/GraphQL/Models/Comment.cs | 25 ++
Core/Core/Api/GraphQL/Models/FileUpload.cs | 30 ++
Core/Core/Api/GraphQL/Models/Model.cs | 23 ++
.../Core/Api/GraphQL/Models/ModelsTreeItem.cs | 17 +
.../Models/PendingStreamCollaborator.cs | 25 ++
Core/Core/Api/GraphQL/Models/Project.cs | 30 ++
.../Api/GraphQL/Models/ProjectCollaborator.cs | 9 +
.../Api/GraphQL/Models/ResourceIdentifier.cs | 10 +
.../Models/Responses/MutationResponses.cs | 42 +++
.../Api/GraphQL/Models/Responses/Responses.cs | 30 ++
Core/Core/Api/GraphQL/Models/ServerInfo.cs | 42 +++
.../GraphQL/Models/SubscriptionMessages.cs | 84 +++++
Core/Core/Api/GraphQL/Models/UserInfo.cs | 55 +++
Core/Core/Api/GraphQL/Models/Version.cs | 18 +
.../Api/GraphQL/Models/ViewerResourceGroup.cs | 11 +
.../Api/GraphQL/Models/ViewerResourceItem.cs | 10 +
.../GraphQL/Resources/ActiveUserResource.cs | 165 +++++++++
.../Api/GraphQL/Resources/CommentResource.cs | 279 ++++++++++++++
.../Api/GraphQL/Resources/ModelResource.cs | 309 ++++++++++++++++
.../GraphQL/Resources/OtherUserResource.cs | 108 ++++++
.../Resources/ProjectInviteResource.cs | 260 +++++++++++++
.../Api/GraphQL/Resources/ProjectResource.cs | 349 ++++++++++++++++++
.../GraphQL/Resources/SubscriptionResource.cs | 216 +++++++++++
.../Api/GraphQL/Resources/VersionResource.cs | 252 +++++++++++++
.../Api/GraphQL/Resources/graphql.config.yml | 2 +
Core/Core/Api/GraphQL/StreamRoles.cs | 12 +
Core/Core/Api/Helpers.cs | 2 +
Core/Core/Api/ServerLimits.cs | 3 +
Core/Core/Credentials/Account.cs | 2 +-
Core/Core/Credentials/AccountManager.cs | 2 +
Core/Core/Credentials/Responses.cs | 43 +--
Core/Core/Credentials/StreamWrapper.cs | 1 +
Core/Core/Logging/SpeckleException.cs | 5 +-
Core/Core/SharpResources.cs | 6 +
.../GraphQL/Legacy/LegacyAPITests.cs} | 7 +-
.../GraphQL/Legacy}/Subscriptions/Branches.cs | 2 +-
.../GraphQL/Legacy}/Subscriptions/Commits.cs | 2 +-
.../GraphQL/Legacy}/Subscriptions/Streams.cs | 2 +-
.../Resources/ActiveUserResourceTests.cs | 51 +++
.../GraphQL/Resources/CommentResourceTests.cs | 97 +++++
.../ModelResourceExceptionalTests.cs | 88 +++++
.../GraphQL/Resources/ModelResourceTests.cs | 96 +++++
.../Resources/OtherUserResourceTests.cs | 49 +++
.../ProjectInviteResourceExceptionalTests.cs | 32 ++
.../Resources/ProjectInviteResourceTests.cs | 107 ++++++
.../ProjectResourceExceptionalTests.cs | 113 ++++++
.../GraphQL/Resources/ProjectResourceTests.cs | 72 ++++
.../Resources/SubscriptionResourceTests.cs | 120 ++++++
.../GraphQL/Resources/VersionResourceTests.cs | 117 ++++++
.../Credentials/UserServerInfoTests.cs | 2 +-
.../Fixtures.cs | 54 ++-
.../GraphQLCLient.cs | 2 +-
.../Api/GraphQLClient.cs | 15 +-
.../AccountServerMigrationTests.cs | 13 +-
.../Credentials/Accounts.cs | 2 +-
.../Transports/TransportTests.cs | 1 -
DesktopUI2/DesktopUI2/DummyBindings.cs | 7 +-
DesktopUI2/DesktopUI2/Utils.cs | 1 +
.../DesktopUI2/ViewModels/AccountViewModel.cs | 1 +
.../ViewModels/NotificationViewModel.cs | 2 +-
98 files changed, 4129 insertions(+), 827 deletions(-)
delete mode 100644 Core/Core/Api/GraphQL/Client.GraphqlCleintOperations/Client.ObsoleteOperations.cs
delete mode 100644 Core/Core/Api/GraphQL/Client.GraphqlCleintOperations/Client.UserOperations.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/FileUploadConversionStatus.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectCommentsUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectFileImportUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectModelsUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectPendingModelsUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectVersionsUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ProjectVisibility.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/ResourceType.cs
create mode 100644 Core/Core/Api/GraphQL/Enums/UserProjectsUpdatedMessageType.cs
create mode 100644 Core/Core/Api/GraphQL/ISpeckleGraphQLClient.cs
create mode 100644 Core/Core/Api/GraphQL/Inputs/CommentInputs.cs
create mode 100644 Core/Core/Api/GraphQL/Inputs/ModelInputs.cs
create mode 100644 Core/Core/Api/GraphQL/Inputs/ProjectInputs.cs
create mode 100644 Core/Core/Api/GraphQL/Inputs/SubscriptionInputs.cs
create mode 100644 Core/Core/Api/GraphQL/Inputs/VersionInputs.cs
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.ActivityOperations.cs (96%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.BranchOperations.cs (86%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.CommentOperations.cs (89%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.CommitOperations.cs (85%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.ObjectOperations.cs (99%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.ServerOperations.cs (96%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.GraphqlCleintOperations/Client.StreamOperations.cs (87%)
create mode 100644 Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.UserOperations.cs
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.Subscriptions/Client.Subscriptions.Branch.cs (100%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.Subscriptions/Client.Subscriptions.Commit.cs (100%)
rename Core/Core/Api/GraphQL/{ => Legacy}/Client.Subscriptions/Client.Subscriptions.Stream.cs (100%)
rename Core/Core/Api/GraphQL/{Models.cs => Legacy/LegacyGraphQLModels.cs} (59%)
create mode 100644 Core/Core/Api/GraphQL/Legacy/Manager.cs
rename Core/Core/Api/GraphQL/{ => Legacy}/SubscriptionModels.cs (74%)
create mode 100644 Core/Core/Api/GraphQL/Models/Collections.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Comment.cs
create mode 100644 Core/Core/Api/GraphQL/Models/FileUpload.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Model.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ModelsTreeItem.cs
create mode 100644 Core/Core/Api/GraphQL/Models/PendingStreamCollaborator.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Project.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ProjectCollaborator.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ResourceIdentifier.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Responses/MutationResponses.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Responses/Responses.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ServerInfo.cs
create mode 100644 Core/Core/Api/GraphQL/Models/SubscriptionMessages.cs
create mode 100644 Core/Core/Api/GraphQL/Models/UserInfo.cs
create mode 100644 Core/Core/Api/GraphQL/Models/Version.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ViewerResourceGroup.cs
create mode 100644 Core/Core/Api/GraphQL/Models/ViewerResourceItem.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/ActiveUserResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/CommentResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/ModelResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/OtherUserResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/ProjectInviteResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/ProjectResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/SubscriptionResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/VersionResource.cs
create mode 100644 Core/Core/Api/GraphQL/Resources/graphql.config.yml
create mode 100644 Core/Core/Api/GraphQL/StreamRoles.cs
create mode 100644 Core/Core/SharpResources.cs
rename Core/Tests/Speckle.Core.Tests.Integration/{Api.cs => Api/GraphQL/Legacy/LegacyAPITests.cs} (98%)
rename Core/Tests/Speckle.Core.Tests.Integration/{ => Api/GraphQL/Legacy}/Subscriptions/Branches.cs (97%)
rename Core/Tests/Speckle.Core.Tests.Integration/{ => Api/GraphQL/Legacy}/Subscriptions/Commits.cs (98%)
rename Core/Tests/Speckle.Core.Tests.Integration/{ => Api/GraphQL/Legacy}/Subscriptions/Streams.cs (97%)
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/CommentResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ModelResourceExceptionalTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/OtherUserResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ProjectResourceExceptionalTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/ProjectResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs
create mode 100644 Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs
diff --git a/Automate/Speckle.Automate.Sdk/AutomationContext.cs b/Automate/Speckle.Automate.Sdk/AutomationContext.cs
index 5844df540a..bacf101565 100644
--- a/Automate/Speckle.Automate.Sdk/AutomationContext.cs
+++ b/Automate/Speckle.Automate.Sdk/AutomationContext.cs
@@ -3,6 +3,7 @@
using Speckle.Automate.Sdk.Schema;
using Speckle.Automate.Sdk.Schema.Triggers;
using Speckle.Core.Api;
+using Speckle.Core.Api.GraphQL.Models;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
diff --git a/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj b/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj
index bbdb0d9a65..3b9b37c95e 100644
--- a/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj
+++ b/Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj
@@ -13,7 +13,7 @@
true
- $(WarningsNotAsErrors);CS8618;
+ $(WarningsNotAsErrors);CS8618;CS0618;
diff --git a/Core/Core/Api/Exceptions.cs b/Core/Core/Api/Exceptions.cs
index 7d10bd9974..f100fd22c3 100644
--- a/Core/Core/Api/Exceptions.cs
+++ b/Core/Core/Api/Exceptions.cs
@@ -9,50 +9,55 @@ namespace Speckle.Core.Api;
///
/// Base class for GraphQL API exceptions
///
-public class SpeckleGraphQLException : SpeckleException
+public class SpeckleGraphQLException : SpeckleGraphQLException
{
- private readonly GraphQLRequest _request;
- public GraphQLResponse? Response { get; }
-
- public SpeckleGraphQLException(string message, GraphQLRequest request, GraphQLResponse? response)
- : base(message)
- {
- _request = request;
- Response = response;
- }
+ public new GraphQLResponse? Response => (GraphQLResponse?)base.Response;
- public SpeckleGraphQLException(string message, Exception inner, GraphQLRequest request, GraphQLResponse? response)
- : this(message, inner)
- {
- _request = request;
- Response = response;
- }
+ public SpeckleGraphQLException(
+ string message,
+ GraphQLRequest request,
+ GraphQLResponse? response,
+ Exception? innerException = null
+ )
+ : base(message, request, response, innerException) { }
public SpeckleGraphQLException() { }
- public SpeckleGraphQLException(string message)
+ public SpeckleGraphQLException(string? message)
: base(message) { }
- public SpeckleGraphQLException(string message, Exception innerException)
+ public SpeckleGraphQLException(string? message, Exception? innerException)
: base(message, innerException) { }
+}
+
+public class SpeckleGraphQLException : SpeckleException
+{
+ private readonly GraphQLRequest _request;
+ public IGraphQLResponse? Response { get; }
public IEnumerable ErrorMessages =>
Response?.Errors != null ? Response.Errors.Select(e => e.Message) : Enumerable.Empty();
public IDictionary? Extensions => Response?.Extensions;
-}
-public class SpeckleGraphQLException : SpeckleGraphQLException