From fba0c46ed81e20fc90a6d9170b27af89d5e3a081 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:52:15 +0000 Subject: [PATCH] Added explicit nullability to GqlModels (#144) * Added explicit nullability to GqlModels * data and alignment * ModelsWithVersions * Models * active user * Invites and active user fixes * Invite changes * Subscriptions * Fixed subscription tests * corrected nullability of projectinput * removed unused mutation responses * format --------- Co-authored-by: Alan Rynne --- Speckle.Sdk.sln.DotSettings | 2 + src/Speckle.Sdk/Api/GraphQL/Client.cs | 14 +- .../Api/GraphQL/ISpeckleGraphQLClient.cs | 2 + .../Api/GraphQL/Inputs/ProjectInputs.cs | 2 +- .../Api/GraphQL/Inputs/UserInputs.cs | 8 ++ .../Api/GraphQL/Models/Activity.cs | 30 ----- .../Api/GraphQL/Models/Collections.cs | 26 +++- src/Speckle.Sdk/Api/GraphQL/Models/Comment.cs | 8 +- .../Api/GraphQL/Models/FileUpload.cs | 9 +- src/Speckle.Sdk/Api/GraphQL/Models/Model.cs | 17 ++- .../Api/GraphQL/Models/ModelsTreeItem.cs | 6 +- .../Models/PendingStreamCollaborator.cs | 8 +- src/Speckle.Sdk/Api/GraphQL/Models/Project.cs | 32 +++-- .../Api/GraphQL/Models/ProjectCollaborator.cs | 5 +- .../Api/GraphQL/Models/ResourceIdentifier.cs | 3 +- .../Models/Responses/MutationResponses.cs | 44 ------- .../Api/GraphQL/Models/Responses/Responses.cs | 40 ++---- .../Api/GraphQL/Models/ServerInfo.cs | 18 ++- src/Speckle.Sdk/Api/GraphQL/Models/User.cs | 14 +- src/Speckle.Sdk/Api/GraphQL/Models/Version.cs | 12 +- .../Api/GraphQL/Models/ViewerResourceGroup.cs | 4 +- .../Api/GraphQL/Models/ViewerResourceItem.cs | 8 +- .../GraphQL/Resources/ActiveUserResource.cs | 107 ++++++++++----- .../Api/GraphQL/Resources/CommentResource.cs | 44 +++---- .../Api/GraphQL/Resources/ModelResource.cs | 60 +++++---- .../GraphQL/Resources/OtherUserResource.cs | 32 ++--- .../Resources/ProjectInviteResource.cs | 56 +++++--- .../Api/GraphQL/Resources/ProjectResource.cs | 86 ++++++------ .../GraphQL/Resources/SubscriptionResource.cs | 10 ++ .../Api/GraphQL/Resources/VersionResource.cs | 123 +++++++++--------- .../Serializer/NewtonsoftJsonSerializer.cs | 11 +- .../Resources/ActiveUserResourceTests.cs | 16 +++ .../GraphQL/Resources/ModelResourceTests.cs | 2 + .../Resources/ProjectInviteResourceTests.cs | 25 ++-- .../Resources/SubscriptionResourceTests.cs | 11 ++ .../GraphQL/Resources/VersionResourceTests.cs | 12 +- 36 files changed, 486 insertions(+), 421 deletions(-) create mode 100644 Speckle.Sdk.sln.DotSettings create mode 100644 src/Speckle.Sdk/Api/GraphQL/Inputs/UserInputs.cs delete mode 100644 src/Speckle.Sdk/Api/GraphQL/Models/Activity.cs delete mode 100644 src/Speckle.Sdk/Api/GraphQL/Models/Responses/MutationResponses.cs diff --git a/Speckle.Sdk.sln.DotSettings b/Speckle.Sdk.sln.DotSettings new file mode 100644 index 00000000..9e5ec22f --- /dev/null +++ b/Speckle.Sdk.sln.DotSettings @@ -0,0 +1,2 @@ + + QL \ No newline at end of file diff --git a/src/Speckle.Sdk/Api/GraphQL/Client.cs b/src/Speckle.Sdk/Api/GraphQL/Client.cs index 2dadff62..5cf2a9e5 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Client.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Client.cs @@ -5,6 +5,7 @@ using GraphQL.Client.Http; using Microsoft.Extensions.Logging; using Speckle.Newtonsoft.Json; +using Speckle.Newtonsoft.Json.Serialization; using Speckle.Sdk.Api.GraphQL; using Speckle.Sdk.Api.GraphQL.Resources; using Speckle.Sdk.Api.GraphQL.Serializer; @@ -272,7 +273,18 @@ private static GraphQLHttpClient CreateGraphQLClient(Account account, HttpClient : null; }, }, - new NewtonsoftJsonSerializer(), + new NewtonsoftJsonSerializer( + new JsonSerializerSettings() + { + ContractResolver = new CamelCasePropertyNamesContractResolver { IgnoreIsSpecifiedMembers = true }, //(Default) + MissingMemberHandling = MissingMemberHandling.Error, //(not default) If you query for a member that doesn't exist, this will throw (except websocket responses see https://github.com/graphql-dotnet/graphql-client/issues/660) + Converters = + { + new ConstantCaseEnumConverter(), + } //(Default) enums will be serialized using the GraphQL const case standard + , + } + ), httpClient ); diff --git a/src/Speckle.Sdk/Api/GraphQL/ISpeckleGraphQLClient.cs b/src/Speckle.Sdk/Api/GraphQL/ISpeckleGraphQLClient.cs index 8d0d99ec..53a4f699 100644 --- a/src/Speckle.Sdk/Api/GraphQL/ISpeckleGraphQLClient.cs +++ b/src/Speckle.Sdk/Api/GraphQL/ISpeckleGraphQLClient.cs @@ -1,4 +1,5 @@ using GraphQL; +using Speckle.Newtonsoft.Json; namespace Speckle.Sdk.Api.GraphQL; @@ -8,6 +9,7 @@ internal interface ISpeckleGraphQLClient /// All other request errors /// The requested a cancel /// This already been disposed + /// The response failed to deserialize, probably because the server version is incompatible with this version of the SDK, or there is a mistake in a query (queried for a property that isn't in the C# model, or a required property was null) internal Task ExecuteGraphQLRequest(GraphQLRequest request, CancellationToken cancellationToken); /// "FORBIDDEN" on "UNAUTHORIZED" response from server diff --git a/src/Speckle.Sdk/Api/GraphQL/Inputs/ProjectInputs.cs b/src/Speckle.Sdk/Api/GraphQL/Inputs/ProjectInputs.cs index 00e6a8d1..e80d3b58 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Inputs/ProjectInputs.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Inputs/ProjectInputs.cs @@ -16,7 +16,7 @@ public sealed record ProjectModelsFilter( IReadOnlyList? ids, bool? onlyWithVersions, string? search, - IReadOnlyList sourceApps + IReadOnlyList? sourceApps ); public sealed record ProjectModelsTreeFilter( diff --git a/src/Speckle.Sdk/Api/GraphQL/Inputs/UserInputs.cs b/src/Speckle.Sdk/Api/GraphQL/Inputs/UserInputs.cs new file mode 100644 index 00000000..58a86b96 --- /dev/null +++ b/src/Speckle.Sdk/Api/GraphQL/Inputs/UserInputs.cs @@ -0,0 +1,8 @@ +namespace Speckle.Sdk.Api.GraphQL.Inputs; + +public sealed record UserUpdateInput( + string? avatar = null, + string? bio = null, + string? company = null, + string? name = null +); diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Activity.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Activity.cs deleted file mode 100644 index 55d92532..00000000 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Activity.cs +++ /dev/null @@ -1,30 +0,0 @@ -#nullable disable -namespace Speckle.Sdk.Api.GraphQL.Models; - -public sealed class Activity -{ - public string actionType { get; init; } - public string id { get; init; } - public Info info { get; init; } - public string message { get; init; } - public string resourceId { get; init; } - public string resourceType { get; init; } - public string streamId { get; init; } - public DateTime time { get; init; } - public string userId { get; init; } -} - -public sealed class Info -{ - public string message { get; init; } - public string sourceApplication { get; init; } - - public InfoCommit commit { get; init; } -} - -public sealed class InfoCommit -{ - public string message { get; init; } - public string sourceApplication { get; init; } - public string branchName { get; init; } -} diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Collections.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Collections.cs index 663ef7a4..10b3d525 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Collections.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Collections.cs @@ -1,17 +1,39 @@ -namespace Speckle.Sdk.Api.GraphQL.Models; +using Speckle.Newtonsoft.Json; + +namespace Speckle.Sdk.Api.GraphQL.Models; public class ResourceCollection { + [property: JsonProperty(Required = Required.Always)] public int totalCount { get; init; } + [property: JsonProperty(Required = Required.Always)] public List items { get; init; } + [property: JsonProperty(Required = Required.AllowNull)] public string? cursor { get; init; } } -public sealed class CommentReplyAuthorCollection : ResourceCollection { } +public sealed class CommentReplyAuthorCollection +{ + [property: JsonProperty(Required = Required.Always)] + public int totalCount { get; init; } + + [property: JsonProperty(Required = Required.Always)] + public List items { get; init; } +} + +public sealed class UserSearchResultCollection +{ + [property: JsonProperty(Required = Required.Always)] + public List items { get; init; } + + [property: JsonProperty(Required = Required.AllowNull)] + public string? cursor { get; init; } +} public sealed class ProjectCommentCollection : ResourceCollection { + [property: JsonProperty(Required = Required.Always)] public int totalArchivedCount { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Comment.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Comment.cs index 3ca53e81..5637f57c 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Comment.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Comment.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class Comment { @@ -10,12 +8,12 @@ public sealed class Comment public DateTime createdAt { get; init; } public bool hasParent { get; init; } public string id { get; init; } - public Comment parent { get; init; } + public Comment? parent { get; init; } public string rawText { get; init; } public ResourceCollection replies { get; init; } public CommentReplyAuthorCollection replyAuthors { get; init; } public List resources { get; init; } - public string screenshot { get; init; } + public string? screenshot { get; init; } public DateTime updatedAt { get; init; } public DateTime? viewedAt { get; init; } public List viewerResources { get; init; } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/FileUpload.cs b/src/Speckle.Sdk/Api/GraphQL/Models/FileUpload.cs index f9c81ddc..09bfccb8 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/FileUpload.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/FileUpload.cs @@ -1,20 +1,19 @@ -#nullable disable - -using Speckle.Sdk.Api.GraphQL.Enums; +using Speckle.Sdk.Api.GraphQL.Enums; namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class FileUpload { - public string convertedCommitId { get; init; } + public string? convertedCommitId { get; init; } public DateTime convertedLastUpdate { get; init; } + public string? convertedMessage { get; init; } public FileUploadConversionStatus convertedStatus { get; init; } public string convertedVersionId { get; init; } public string fileName { get; init; } public int fileSize { get; init; } public string fileType { get; init; } public string id { get; init; } - public Model model { get; init; } + public Model? model { get; init; } public string modelName { get; init; } public string projectId { get; init; } public bool uploadComplete { get; init; } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Model.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Model.cs index 4d7acb20..c22408c3 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Model.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Model.cs @@ -1,19 +1,18 @@ -#nullable disable -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; -public sealed class Model +public class Model { public LimitedUser author { get; init; } - public List childrenTree { get; init; } - public ResourceCollection commentThreads { get; init; } public DateTime createdAt { get; init; } - public string description { get; init; } + public string? description { get; init; } public string displayName { get; init; } public string id { get; init; } public string name { get; init; } - public List pendingImportedVersions { get; init; } - public Uri previewUrl { get; init; } + public Uri? previewUrl { get; init; } public DateTime updatedAt { get; init; } +} + +public sealed class ModelWithVersions : Model +{ public ResourceCollection versions { get; init; } - public Version version { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ModelsTreeItem.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ModelsTreeItem.cs index 2b93e210..74bf6a82 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ModelsTreeItem.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ModelsTreeItem.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class ModelsTreeItem { @@ -8,7 +6,7 @@ public sealed class ModelsTreeItem public string fullName { get; init; } public bool hasChildren { get; init; } public string id { get; init; } - public Model model { get; init; } + public Model? model { get; init; } public string name { get; init; } public DateTime updatedAt { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/PendingStreamCollaborator.cs b/src/Speckle.Sdk/Api/GraphQL/Models/PendingStreamCollaborator.cs index b9110664..4398944f 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/PendingStreamCollaborator.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/PendingStreamCollaborator.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class PendingStreamCollaborator { @@ -13,6 +11,6 @@ public sealed class PendingStreamCollaborator public string title { get; init; } public string role { get; init; } public LimitedUser invitedBy { get; init; } - public LimitedUser user { get; init; } - public string token { get; init; } + public LimitedUser? user { get; init; } + public string? token { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Project.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Project.cs index 7ce9ae34..f2ca4344 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Project.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Project.cs @@ -1,30 +1,28 @@ -#nullable disable -using Speckle.Sdk.Api.GraphQL.Enums; +using Speckle.Sdk.Api.GraphQL.Enums; namespace Speckle.Sdk.Api.GraphQL.Models; -public sealed class Project +public class Project { - public bool AllowPublicComments { get; init; } - public ProjectCommentCollection commentThreads { get; init; } + public bool allowPublicComments { get; init; } public DateTime createdAt { get; init; } - public string description { get; init; } + public string? description { get; init; } public string id { get; init; } - public List invitedTeam { get; init; } - public ResourceCollection models { get; init; } public string name { get; init; } - public List pendingImportedModels { get; init; } - public string role { get; init; } + public string? role { get; init; } public List sourceApps { get; init; } - public List team { get; init; } public DateTime updatedAt { get; init; } public ProjectVisibility visibility { get; init; } + public string? workspaceId { get; init; } +} - public List viewerResources { get; init; } - public ResourceCollection versions { get; init; } - public Model model { get; init; } - public List modelChildrenTree { get; init; } - public ResourceCollection modelsTree { get; init; } +public sealed class ProjectWithModels : Project +{ + public ResourceCollection models { get; init; } +} - public string workspaceId { get; init; } +public sealed class ProjectWithTeam : Project +{ + public List invitedTeam { get; init; } + public List team { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ProjectCollaborator.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ProjectCollaborator.cs index 232eb82e..81c02af1 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ProjectCollaborator.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ProjectCollaborator.cs @@ -1,9 +1,8 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class ProjectCollaborator { + public string id { get; init; } public string role { get; init; } public LimitedUser user { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ResourceIdentifier.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ResourceIdentifier.cs index adeb2252..af9dda29 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ResourceIdentifier.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ResourceIdentifier.cs @@ -1,5 +1,4 @@ -#nullable disable -using Speckle.Sdk.Api.GraphQL.Enums; +using Speckle.Sdk.Api.GraphQL.Enums; namespace Speckle.Sdk.Api.GraphQL.Models; diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Responses/MutationResponses.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Responses/MutationResponses.cs deleted file mode 100644 index d5096444..00000000 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Responses/MutationResponses.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Speckle.Sdk.Api.GraphQL.Models.Responses; - -#nullable disable -internal sealed class ProjectMutation -{ - public Project create { get; init; } - public Project update { get; init; } - public bool delete { get; init; } - public ProjectInviteMutation invites { get; init; } - - public Project updateRole { get; init; } -} - -internal sealed class ProjectInviteMutation -{ - public Project create { get; init; } - public bool use { get; init; } - public Project cancel { get; init; } -} - -internal sealed class ModelMutation -{ - public Model create { get; init; } - public Model update { get; init; } - public bool delete { get; init; } -} - -internal sealed class VersionMutation -{ - public Version create { get; init; } - public bool delete { get; init; } - public bool markReceived { get; init; } - public Model moveToModel { get; init; } - public Version update { get; init; } -} - -internal sealed class CommentMutation -{ - public bool archive { get; init; } - public Comment create { get; init; } - public Comment edit { get; init; } - public bool markViewed { get; init; } - public Comment reply { get; init; } -} diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Responses/Responses.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Responses/Responses.cs index e84ffd70..8c032b4c 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Responses/Responses.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Responses/Responses.cs @@ -2,29 +2,17 @@ namespace Speckle.Sdk.Api.GraphQL.Models.Responses; -// This file holds simple records that represent the root GraphQL response data -// For this reason, we're keeping them internal, allowing us to be flexible without the concern for breaking. -// It also exposes fewer similarly named types to dependent assemblies - -internal record ProjectResponse([property: JsonRequired] Project project); - -internal record ActiveUserResponse(User? activeUser); - -internal record LimitedUserResponse(LimitedUser? otherUser); - -internal record ServerInfoResponse([property: JsonRequired] ServerInfo serverInfo); - -internal record ProjectMutationResponse([property: JsonRequired] ProjectMutation projectMutations); - -internal record ModelMutationResponse([property: JsonRequired] ModelMutation modelMutations); - -internal record VersionMutationResponse([property: JsonRequired] VersionMutation versionMutations); - -internal record ProjectInviteResponse(PendingStreamCollaborator? projectInvite); - -internal record UserSearchResponse([property: JsonRequired] ResourceCollection userSearch); - -//All of the above records could be replaced by either RequiredResponse or OptionalResponse, if we use an alias (see https://www.baeldung.com/graphql-field-name) -internal record RequiredResponse([property: JsonRequired] T data); - -internal record OptionalResponse(T? data); +/// +/// With the power of GraphQL Aliasing, we can avoid having to craft individual response classes for each query +/// Instead, we can alias the query object as data, and use either or +/// To deserialize the response +/// +/// +/// +internal record RequiredResponse([property: JsonProperty(Required = Required.Always)] T data); + +/// +internal record NullableResponse([property: JsonProperty(Required = Required.AllowNull)] T? data); + +//TODO: replace with RequiredResponse{T} +internal record ServerInfoResponse([property: JsonProperty(Required = Required.Always)] ServerInfo serverInfo); diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ServerInfo.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ServerInfo.cs index 89533649..8f044732 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ServerInfo.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ServerInfo.cs @@ -1,11 +1,19 @@ namespace Speckle.Sdk.Api.GraphQL.Models; +public sealed class AuthStrategy +{ + public string? color { get; init; } + public string icon { get; init; } + public string id { get; init; } + public string name { get; init; } + public string url { get; init; } +} + public sealed class ServerInfo { public string name { get; init; } public string? company { get; init; } public string? version { get; init; } - public string? adminContact { get; init; } public string? description { get; init; } /// @@ -28,12 +36,12 @@ public sealed class ServerInfo public sealed class ServerMigration { /// - /// New URI where this server is now deployed + /// Previous URI where this server used to be deployed /// - public Uri? movedTo { get; set; } + public Uri? movedFrom { get; set; } /// - /// Previous URI where this server used to be deployed + /// New URI where this server is now deployed /// - public Uri? movedFrom { get; set; } + public Uri? movedTo { get; set; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/User.cs b/src/Speckle.Sdk/Api/GraphQL/Models/User.cs index 0e3990f0..57fef330 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/User.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/User.cs @@ -1,15 +1,13 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public abstract class UserBase { - public string avatar { get; init; } - public string bio { get; init; } - public string company { get; set; } + public string? avatar { get; init; } + public string? bio { get; init; } + public string? company { get; set; } public string id { get; init; } public string name { get; init; } - public string role { get; init; } + public string? role { get; init; } public bool? verified { get; init; } } @@ -24,7 +22,7 @@ public override string ToString() public sealed class User : UserBase { public DateTime? createdAt { get; init; } - public string email { get; init; } + public string? email { get; init; } public bool? hasPendingVerification { get; init; } public bool? isOnboardingFinished { get; init; } public List projectInvites { get; init; } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/Version.cs b/src/Speckle.Sdk/Api/GraphQL/Models/Version.cs index b0ec7854..ecc5d3e8 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/Version.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/Version.cs @@ -1,16 +1,12 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public sealed class Version { - public LimitedUser authorUser { get; init; } - public ResourceCollection commentThreads { get; init; } + public LimitedUser? authorUser { get; init; } public DateTime createdAt { get; init; } public string id { get; init; } - public string message { get; init; } - public Model model { get; init; } + public string? message { get; init; } public Uri previewUrl { get; init; } public string referencedObject { get; init; } - public string sourceApplication { get; init; } + public string? sourceApplication { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceGroup.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceGroup.cs index 7dbd6533..d38de688 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceGroup.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceGroup.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public class ViewerResourceGroup { diff --git a/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceItem.cs b/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceItem.cs index d87d8af5..e61a9a1f 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceItem.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Models/ViewerResourceItem.cs @@ -1,10 +1,8 @@ -#nullable disable - -namespace Speckle.Sdk.Api.GraphQL.Models; +namespace Speckle.Sdk.Api.GraphQL.Models; public class ViewerResourceItem { - public string modelId { get; init; } + public string? modelId { get; init; } public string objectId { get; init; } - public string versionId { get; init; } + public string? versionId { get; init; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ActiveUserResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ActiveUserResource.cs index fd2c7c3d..3dd3bb0e 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ActiveUserResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ActiveUserResource.cs @@ -15,37 +15,68 @@ internal ActiveUserResource(ISpeckleGraphQLClient client) } /// - /// Gets the currently active user profile. + /// Gets the currently active user profile (as extracted from the authorization header) /// /// /// - /// the requested user, or null if the user does not exist (i.e. was initialised with an unauthenticated account) + /// the requested user, or null if was initialised with an unauthenticated account /// public async Task Get(CancellationToken cancellationToken = default) { //language=graphql const string QUERY = """ query User { - activeUser { - id, - email, - name, - bio, - company, - avatar, - verified, - profiles, - role, + data:activeUser { + id + email + name + bio + company + avatar + verified + role } } """; var request = new GraphQLRequest { Query = QUERY }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.activeUser; + return response.data; + } + + /// + /// + /// + public async Task Update(UserUpdateInput input, CancellationToken cancellationToken = default) + { + //todo:test + //language=graphql + const string QUERY = """ + mutation ActiveUserMutations($input: UserUpdateInput!) { + data:activeUserMutations { + data:update(user: $input) { + id + email + name + bio + company + avatar + verified + role + } + } + } + """; + var request = new GraphQLRequest { Query = QUERY, Variables = new { input } }; + + var response = await _client + .ExecuteGraphQLRequest>>(request, cancellationToken) + .ConfigureAwait(false); + + return response.data.data; } /// Max number of projects to fetch @@ -64,9 +95,10 @@ public async Task> GetProjects( //language=graphql const string QUERY = """ query User($limit : Int!, $cursor: String, $filter: UserProjectsFilter) { - activeUser { - projects(limit: $limit, cursor: $cursor, filter: $filter) { + data:activeUser { + data:projects(limit: $limit, cursor: $cursor, filter: $filter) { totalCount + cursor items { id name @@ -77,6 +109,7 @@ query User($limit : Int!, $cursor: String, $filter: UserProjectsFilter) { createdAt updatedAt sourceApps + workspaceId } } } @@ -94,27 +127,30 @@ query User($limit : Int!, $cursor: String, $filter: UserProjectsFilter) { }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>?>>( + request, + cancellationToken + ) .ConfigureAwait(false); - if (response.activeUser is null) + if (response.data is null) { throw new SpeckleGraphQLException("GraphQL response indicated that the ActiveUser could not be found"); } - return response.activeUser.projects; + return response.data.data; } /// /// /// - public async Task> ProjectInvites(CancellationToken cancellationToken = default) + public async Task> GetProjectInvites(CancellationToken cancellationToken = default) { //language=graphql const string QUERY = """ query ProjectInvites { - activeUser { - projectInvites { + data:activeUser { + data:projectInvites { id inviteId invitedBy { @@ -132,12 +168,13 @@ query ProjectInvites { title token user { - id, - name, - bio, - company, - verified, - role, + id + name + bio + company + verified + avatar + role } } } @@ -147,14 +184,22 @@ query ProjectInvites { var request = new GraphQLRequest { Query = QUERY }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>?>>( + request, + cancellationToken + ) .ConfigureAwait(false); - if (response.activeUser is null) + if (response.data is null) { throw new SpeckleGraphQLException("GraphQL response indicated that the ActiveUser could not be found"); } - return response.activeUser.projectInvites; + return response.data.data; } + + /// + [Obsolete($"Renamed to {nameof(GetProjectInvites)}")] + public async Task> ProjectInvites(CancellationToken cancellationToken = default) => + await GetProjectInvites(cancellationToken).ConfigureAwait(false); } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs index 1159e372..12180b6b 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs @@ -23,7 +23,7 @@ internal CommentResource(ISpeckleGraphQLClient client) /// /// /// - public async Task> GetProjectComments( + public async Task GetProjectComments( string projectId, int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST, string? cursor = null, @@ -36,8 +36,8 @@ public async Task> GetProjectComments( //language=graphql const string QUERY = """ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter: ProjectCommentsFilter, $repliesLimit: Int, $repliesCursor: String) { - project(id: $projectId) { - commentThreads(cursor: $cursor, limit: $limit, filter: $filter) { + data:project(id: $projectId) { + data:commentThreads(cursor: $cursor, limit: $limit, filter: $filter) { cursor totalArchivedCount totalCount @@ -74,7 +74,6 @@ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter objectId versionId } - data } } } @@ -97,10 +96,10 @@ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.project.commentThreads; + return response.data.data; } /// @@ -117,7 +116,7 @@ internal async Task Create(CreateCommentInput input, CancellationToken const string QUERY = """ mutation Mutation($input: CreateCommentInput!) { data:commentMutations { - create(input: $input) { + data:create(input: $input) { archived authorId createdAt @@ -136,16 +135,15 @@ mutation Mutation($input: CreateCommentInput!) { objectId versionId } - data } } } """; GraphQLRequest request = new(QUERY, variables: new { input }); var res = await _client - .ExecuteGraphQLRequest>(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.data.create; + return res.data.data; } /// @@ -159,7 +157,7 @@ internal async Task Edit(EditCommentInput input, CancellationToken canc const string QUERY = """ mutation Mutation($input: EditCommentInput!) { data:commentMutations { - edit(input: $input) { + data:edit(input: $input) { archived authorId createdAt @@ -178,16 +176,15 @@ mutation Mutation($input: EditCommentInput!) { objectId versionId } - data } } } """; GraphQLRequest request = new(QUERY, variables: new { input }); var res = await _client - .ExecuteGraphQLRequest>(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.data.edit; + return res.data.data; } /// @@ -201,15 +198,15 @@ public async Task Archive(string commentId, bool archive = true, Cancellat const string QUERY = """ mutation Mutation($commentId: String!, $archive: Boolean!) { data:commentMutations { - archive(commentId: $commentId, archived: $archive) + data:archive(commentId: $commentId, archived: $archive) } } """; GraphQLRequest request = new(QUERY, variables: new { commentId, archive }); var res = await _client - .ExecuteGraphQLRequest>(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.data.archive; + return res.data.data; } /// @@ -222,15 +219,15 @@ public async Task MarkViewed(string commentId, CancellationToken cancellat const string QUERY = """ mutation Mutation($commentId: String!) { data:commentMutations { - markViewed(commentId: $commentId) + data:markViewed(commentId: $commentId) } } """; GraphQLRequest request = new(QUERY, variables: new { commentId }); var res = await _client - .ExecuteGraphQLRequest>(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.data.markViewed; + return res.data.data; } /// @@ -244,7 +241,7 @@ internal async Task Reply(CreateCommentReplyInput input, CancellationTo const string QUERY = """ mutation Mutation($input: CreateCommentReplyInput!) { data:commentMutations { - reply(input: $input) { + data:reply(input: $input) { archived authorId createdAt @@ -263,15 +260,14 @@ mutation Mutation($input: CreateCommentReplyInput!) { objectId versionId } - data } } } """; GraphQLRequest request = new(QUERY, variables: new { input }); var res = await _client - .ExecuteGraphQLRequest>(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.data.reply; + return res.data.data; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs index c068e7a0..df13629b 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs @@ -25,8 +25,8 @@ public async Task Get(string modelId, string projectId, CancellationToken //language=graphql const string QUERY = """ query ModelGet($modelId: String!, $projectId: String!) { - project(id: $projectId) { - model(id: $modelId) { + data:project(id: $projectId) { + data:model(id: $modelId) { id name previewUrl @@ -50,10 +50,10 @@ query ModelGet($modelId: String!, $projectId: String!) { var request = new GraphQLRequest { Query = QUERY, Variables = new { modelId, projectId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.project.model; + return response.data.data; } /// @@ -65,7 +65,7 @@ query ModelGet($modelId: String!, $projectId: String!) { /// /// /// - public async Task GetWithVersions( + public async Task GetWithVersions( string modelId, string projectId, int versionsLimit = ServerLimits.DEFAULT_PAGINATION_REQUEST, @@ -77,8 +77,8 @@ public async Task GetWithVersions( //language=graphql const string QUERY = """ query ModelGetWithVersions($modelId: String!, $projectId: String!, $versionsLimit: Int!, $versionsCursor: String, $versionsFilter: ModelVersionsFilter) { - project(id: $projectId) { - model(id: $modelId) { + data:project(id: $projectId) { + data:model(id: $modelId) { id name previewUrl @@ -92,6 +92,7 @@ query ModelGetWithVersions($modelId: String!, $projectId: String!, $versionsLimi createdAt previewUrl authorUser { + avatar id name bio @@ -134,10 +135,10 @@ query ModelGetWithVersions($modelId: String!, $projectId: String!, $versionsLimi }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.project.model; + return response.data.data; } /// @@ -158,8 +159,8 @@ public async Task> GetModels( //language=graphql const string QUERY = """ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCursor: String, $modelsFilter: ProjectModelsFilter) { - project(id: $projectId) { - models(limit: $modelsLimit, cursor: $modelsCursor, filter: $modelsFilter) { + data:project(id: $projectId) { + data:models(limit: $modelsLimit, cursor: $modelsCursor, filter: $modelsFilter) { items { id name @@ -168,6 +169,15 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso displayName description createdAt + author { + avatar + bio + company + id + name + role + verified + } } totalCount cursor @@ -189,9 +199,9 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>(request, cancellationToken) .ConfigureAwait(false); - return response.project.models; + return response.data.data; } /// @@ -203,8 +213,8 @@ public async Task Create(CreateModelInput input, CancellationToken cancel //language=graphql const string QUERY = """ mutation ModelCreate($input: CreateModelInput!) { - modelMutations { - create(input: $input) { + data:modelMutations { + data:create(input: $input) { id displayName name @@ -229,10 +239,10 @@ mutation ModelCreate($input: CreateModelInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var res = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.modelMutations.create; + return res.data.data; } /// @@ -244,8 +254,8 @@ public async Task Delete(DeleteModelInput input, CancellationToken cancell //language=graphql const string QUERY = """ mutation ModelDelete($input: DeleteModelInput!) { - modelMutations { - delete(input: $input) + data:modelMutations { + data:delete(input: $input) } } """; @@ -253,10 +263,10 @@ mutation ModelDelete($input: DeleteModelInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var res = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.modelMutations.delete; + return res.data.data; } /// @@ -268,8 +278,8 @@ public async Task Update(UpdateModelInput input, CancellationToken cancel //language=graphql const string QUERY = """ mutation ModelUpdate($input: UpdateModelInput!) { - modelMutations { - update(input: $input) { + data:modelMutations { + data:update(input: $input) { id name displayName @@ -294,9 +304,9 @@ mutation ModelUpdate($input: UpdateModelInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var res = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return res.modelMutations.update; + return res.data.data; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/OtherUserResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/OtherUserResource.cs index 512751bb..309d1255 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/OtherUserResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/OtherUserResource.cs @@ -25,14 +25,14 @@ internal OtherUserResource(ISpeckleGraphQLClient client) //language=graphql const string QUERY = """ query LimitedUser($id: String!) { - otherUser(id: $id){ - id, - name, - bio, - company, - avatar, - verified, - role, + data:otherUser(id: $id) { + id + name + bio + company + avatar + verified + role } } """; @@ -40,14 +40,14 @@ query LimitedUser($id: String!) { var request = new GraphQLRequest { Query = QUERY, Variables = new { id } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.otherUser; + return response.data; } /// - /// Searches for a user on the server. + /// Searches for a user on the server, by name or email /// /// String to search for. Must be at least 3 characters /// Max number of users to fetch @@ -57,7 +57,7 @@ query LimitedUser($id: String!) { /// /// /// - public async Task> UserSearch( + public async Task UserSearch( string query, int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST, string? cursor = null, @@ -69,8 +69,8 @@ public async Task> UserSearch( //language=graphql const string QUERY = """ query UserSearch($query: String!, $limit: Int!, $cursor: String, $archived: Boolean, $emailOnly: Boolean) { - userSearch(query: $query, limit: $limit, cursor: $cursor, archived: $archived, emailOnly: $emailOnly) { - cursor, + data:userSearch(query: $query, limit: $limit, cursor: $cursor, archived: $archived, emailOnly: $emailOnly) { + cursor items { id name @@ -98,9 +98,9 @@ query UserSearch($query: String!, $limit: Int!, $cursor: String, $archived: Bool }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.userSearch; + return response.data; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectInviteResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectInviteResource.cs index cd122a59..50d7f818 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectInviteResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectInviteResource.cs @@ -19,7 +19,7 @@ internal ProjectInviteResource(ISpeckleGraphQLClient client) /// /// /// - public async Task Create( + public async Task Create( string projectId, ProjectInviteCreateInput input, CancellationToken cancellationToken = default @@ -28,9 +28,9 @@ public async Task Create( //language=graphql const string QUERY = """ mutation ProjectInviteCreate($projectId: ID!, $input: ProjectInviteCreateInput!) { - projectMutations { - invites { - create(projectId: $projectId, input: $input) { + data:projectMutations { + data:invites { + data:create(projectId: $projectId, input: $input) { id name description @@ -39,7 +39,10 @@ mutation ProjectInviteCreate($projectId: ID!, $input: ProjectInviteCreateInput!) role createdAt updatedAt + workspaceId + sourceApps team { + id role user { id @@ -86,10 +89,13 @@ mutation ProjectInviteCreate($projectId: ID!, $input: ProjectInviteCreateInput!) GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId, input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>( + request, + cancellationToken + ) .ConfigureAwait(false); - return response.projectMutations.invites.create; + return response.data.data.data; } /// @@ -101,9 +107,9 @@ public async Task Use(ProjectInviteUseInput input, CancellationToken cance //language=graphql const string QUERY = """ mutation ProjectInviteUse($input: ProjectInviteUseInput!) { - projectMutations { - invites { - use(input: $input) + data:projectMutations { + data:invites { + data:use(input: $input) } } } @@ -111,9 +117,9 @@ mutation ProjectInviteUse($input: ProjectInviteUseInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>(request, cancellationToken) .ConfigureAwait(false); - return response.projectMutations.invites.use; + return response.data.data.data; } /// @@ -130,7 +136,7 @@ mutation ProjectInviteUse($input: ProjectInviteUseInput!) { //language=graphql const string QUERY = """ query ProjectInvite($projectId: String!, $token: String) { - projectInvite(projectId: $projectId, token: $token) { + data:projectInvite(projectId: $projectId, token: $token) { id inviteId invitedBy { @@ -162,10 +168,10 @@ query ProjectInvite($projectId: String!, $token: String) { GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId, token } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.projectInvite; + return response.data; } /// @@ -173,14 +179,18 @@ query ProjectInvite($projectId: String!, $token: String) { /// /// /// - public async Task Cancel(string projectId, string inviteId, CancellationToken cancellationToken = default) + public async Task Cancel( + string projectId, + string inviteId, + CancellationToken cancellationToken = default + ) { //language=graphql const string QUERY = """ mutation ProjectInviteCancel($projectId: ID!, $inviteId: String!) { - projectMutations { - invites { - cancel(projectId: $projectId, inviteId: $inviteId) { + data:projectMutations { + data:invites { + data:cancel(projectId: $projectId, inviteId: $inviteId) { id name description @@ -189,7 +199,10 @@ mutation ProjectInviteCancel($projectId: ID!, $inviteId: String!) { role createdAt updatedAt + sourceApps + workspaceId team { + id role user { id @@ -236,9 +249,12 @@ mutation ProjectInviteCancel($projectId: ID!, $inviteId: String!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId, inviteId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>( + request, + cancellationToken + ) .ConfigureAwait(false); - return response.projectMutations.invites.cancel; + return response.data.data.data; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectResource.cs index c160cb2e..20905f2c 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ProjectResource.cs @@ -25,16 +25,16 @@ public async Task Get(string projectId, CancellationToken cancellationT //language=graphql const string QUERY = """ query Project($projectId: String!) { - project(id: $projectId) { + data:project(id: $projectId) { + allowPublicComments + createdAt + description id name - description - visibility - allowPublicComments role - createdAt - updatedAt sourceApps + updatedAt + visibility workspaceId } } @@ -42,9 +42,9 @@ query Project($projectId: String!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.project; + return response.data; } /// @@ -56,7 +56,7 @@ query Project($projectId: String!) { /// /// /// - public async Task GetWithModels( + public async Task GetWithModels( string projectId, int modelsLimit = ServerLimits.DEFAULT_PAGINATION_REQUEST, string? modelsCursor = null, @@ -67,7 +67,7 @@ public async Task GetWithModels( //language=graphql const string QUERY = """ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCursor: String, $modelsFilter: ProjectModelsFilter) { - project(id: $projectId) { + data:project(id: $projectId) { id name description @@ -77,6 +77,7 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso createdAt updatedAt sourceApps + workspaceId models(limit: $modelsLimit, cursor: $modelsCursor, filter: $modelsFilter) { items { id @@ -107,9 +108,9 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.project; + return response.data; } /// @@ -118,12 +119,12 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso /// /// /// - public async Task GetWithTeam(string projectId, CancellationToken cancellationToken = default) + public async Task GetWithTeam(string projectId, CancellationToken cancellationToken = default) { //language=graphql const string QUERY = """ query ProjectGetWithTeam($projectId: String!) { - project(id: $projectId) { + data:project(id: $projectId) { id name description @@ -132,7 +133,10 @@ query ProjectGetWithTeam($projectId: String!) { role createdAt updatedAt + workspaceId + sourceApps team { + id role user { id @@ -178,9 +182,9 @@ query ProjectGetWithTeam($projectId: String!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>(request, cancellationToken) .ConfigureAwait(false); - return response.project; + return response.data; } /// @@ -192,8 +196,8 @@ public async Task Create(ProjectCreateInput input, CancellationToken ca //language=graphql const string QUERY = """ mutation ProjectCreate($input: ProjectCreateInput) { - projectMutations { - create(input: $input) { + data:projectMutations { + data:create(input: $input) { id name description @@ -211,9 +215,9 @@ mutation ProjectCreate($input: ProjectCreateInput) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.projectMutations.create; + return response.data.data; } /// @@ -225,16 +229,17 @@ public async Task Update(ProjectUpdateInput input, CancellationToken ca //language=graphql const string QUERY = """ mutation ProjectUpdate($input: ProjectUpdateInput!) { - projectMutations{ - update(update: $input) { + data:projectMutations{ + data:update(update: $input) { + allowPublicComments + createdAt + description id name - description - visibility - allowPublicComments role - createdAt + sourceApps updatedAt + visibility workspaceId } } @@ -243,9 +248,9 @@ mutation ProjectUpdate($input: ProjectUpdateInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.projectMutations.update; + return response.data.data; } /// The id of the Project to delete @@ -257,29 +262,32 @@ public async Task Delete(string projectId, CancellationToken cancellationT //language=graphql const string QUERY = """ mutation ProjectDelete($projectId: String!) { - projectMutations { - delete(id: $projectId) + data:projectMutations { + data:delete(id: $projectId) } } """; GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.projectMutations.delete; + return response.data.data; } /// /// /// - public async Task UpdateRole(ProjectUpdateRoleInput input, CancellationToken cancellationToken = default) + public async Task UpdateRole( + ProjectUpdateRoleInput input, + CancellationToken cancellationToken = default + ) { //language=graphql const string QUERY = """ mutation ProjectUpdateRole($input: ProjectUpdateRoleInput!) { - projectMutations { - updateRole(input: $input) { + data:projectMutations { + data:updateRole(input: $input) { id name description @@ -288,7 +296,10 @@ mutation ProjectUpdateRole($input: ProjectUpdateRoleInput!) { role createdAt updatedAt + sourceApps + workspaceId team { + id role user { id @@ -327,7 +338,6 @@ mutation ProjectUpdateRole($input: ProjectUpdateRoleInput!) { role } } - workspaceId } } } @@ -335,8 +345,8 @@ mutation ProjectUpdateRole($input: ProjectUpdateRoleInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.projectMutations.updateRole; + return response.data.data; } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs index 916768f7..f23edae9 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs @@ -51,6 +51,15 @@ subscription UserProjectsUpdated { id project { id + name + description + visibility + allowPublicComments + role + createdAt + updatedAt + sourceApps + workspaceId } type } @@ -151,6 +160,7 @@ subscription ProjectUpdated($id: String!) { createdAt updatedAt sourceApps + workspaceId } type } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/VersionResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/VersionResource.cs index 6245a6ab..2188a185 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/VersionResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/VersionResource.cs @@ -16,60 +16,42 @@ internal VersionResource(ISpeckleGraphQLClient client) } /// - /// /// /// /// /// - public async Task Get( - string versionId, - string modelId, - string projectId, - CancellationToken cancellationToken = default - ) + public async Task Get(string versionId, string projectId, CancellationToken cancellationToken = default) { //language=graphql const string QUERY = """ - query VersionGet($projectId: String!, $modelId: String!, $versionId: String!) { - project(id: $projectId) { - model(id: $modelId) { - version(id: $versionId) { + query VersionGet($projectId: String!, $versionId: String!) { + data:project(id: $projectId) { + data:version(id: $versionId) { + id + referencedObject + message + sourceApplication + createdAt + previewUrl + authorUser { id - referencedObject - message - sourceApplication - createdAt - previewUrl - authorUser { - id - name - bio - company - verified - role - avatar - } + name + bio + company + verified + role + avatar } } } } """; - GraphQLRequest request = - new() - { - Query = QUERY, - Variables = new - { - projectId, - modelId, - versionId, - }, - }; + GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId, versionId } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.project.model.version; + return response.data.data; } /// @@ -91,9 +73,9 @@ public async Task> GetVersions( //language=graphql const string QUERY = """ query VersionGetVersions($projectId: String!, $modelId: String!, $limit: Int!, $cursor: String, $filter: ModelVersionsFilter) { - project(id: $projectId) { - model(id: $modelId) { - versions(limit: $limit, cursor: $cursor, filter: $filter) { + data:project(id: $projectId) { + data:model(id: $modelId) { + data:versions(limit: $limit, cursor: $cursor, filter: $filter) { items { id referencedObject @@ -134,9 +116,12 @@ query VersionGetVersions($projectId: String!, $modelId: String!, $limit: Int!, $ }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>>( + request, + cancellationToken + ) .ConfigureAwait(false); - return response.project.model.versions; + return response.data.data.data; } /// @@ -148,9 +133,9 @@ public async Task Create(CreateVersionInput input, CancellationToken can //language=graphql const string QUERY = """ mutation Create($input: CreateVersionInput!) { - versionMutations { - create(input: $input) { - id + data:versionMutations { + data:create(input: $input) { + data:id } } } @@ -159,9 +144,9 @@ mutation Create($input: CreateVersionInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>(request, cancellationToken) .ConfigureAwait(false); - return response.versionMutations.create.id; + return response.data.data.data; } /// @@ -172,8 +157,8 @@ public async Task Update(UpdateVersionInput input, CancellationToken ca //language=graphql const string QUERY = """ mutation VersionUpdate($input: UpdateVersionInput!) { - versionMutations { - update(input: $input) { + data:versionMutations { + data:update(input: $input) { id referencedObject message @@ -196,9 +181,9 @@ mutation VersionUpdate($input: UpdateVersionInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.versionMutations.update; + return response.data.data; } /// @@ -210,9 +195,9 @@ public async Task MoveToModel(MoveVersionsInput input, CancellationToken //language=graphql const string QUERY = """ mutation VersionMoveToModel($input: MoveVersionsInput!) { - versionMutations { - moveToModel(input: $input) { - id + data:versionMutations { + data:moveToModel(input: $input) { + data:id } } } @@ -220,9 +205,9 @@ mutation VersionMoveToModel($input: MoveVersionsInput!) { GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>>(request, cancellationToken) .ConfigureAwait(false); - return response.versionMutations.moveToModel.id; + return response.data.data.data; } /// @@ -234,18 +219,18 @@ public async Task Delete(DeleteVersionsInput input, CancellationToken canc //language=graphql const string QUERY = """ mutation VersionDelete($input: DeleteVersionsInput!) { - versionMutations { - delete(input: $input) + data:versionMutations { + data:delete(input: $input) } } """; GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.versionMutations.delete; + return response.data.data; } /// @@ -257,17 +242,25 @@ public async Task Received(MarkReceivedVersionInput input, CancellationTok //language=graphql const string QUERY = """ mutation MarkReceived($input: MarkReceivedVersionInput!) { - versionMutations { - markReceived(input: $input) + data:versionMutations { + data:markReceived(input: $input) } } """; GraphQLRequest request = new() { Query = QUERY, Variables = new { input } }; var response = await _client - .ExecuteGraphQLRequest(request, cancellationToken) + .ExecuteGraphQLRequest>>(request, cancellationToken) .ConfigureAwait(false); - return response.versionMutations.markReceived; + return response.data.data; } + + [Obsolete("modelId is no longer required, use the overload that doesn't specify a model id")] + public Task Get( + string versionId, + string modelId, + string projectId, + CancellationToken cancellationToken = default + ) => throw new NotImplementedException(); } diff --git a/src/Speckle.Sdk/Api/GraphQL/Serializer/NewtonsoftJsonSerializer.cs b/src/Speckle.Sdk/Api/GraphQL/Serializer/NewtonsoftJsonSerializer.cs index fdee7bb1..c7c0d51c 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Serializer/NewtonsoftJsonSerializer.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Serializer/NewtonsoftJsonSerializer.cs @@ -46,7 +46,7 @@ public byte[] SerializeToBytes(GraphQLWebSocketRequest request) public Task DeserializeToWebsocketResponseWrapperAsync(System.IO.Stream stream) { - return DeserializeFromUtf8Stream(stream); + return DeserializeFromUtf8Stream(stream, DefaultJsonSerializerSettings); //Ignoring the custom JsonSerializerSettings here, see https://github.com/graphql-dotnet/graphql-client/issues/660 } public GraphQLWebSocketResponse DeserializeToWebsocketResponse(byte[] bytes) @@ -62,7 +62,7 @@ public Task> DeserializeFromUtf8StreamAsync>(stream); + return DeserializeFromUtf8Stream>(stream, JsonSerializerSettings); } // deserialize extensions to Dictionary @@ -71,11 +71,14 @@ private void ConfigureMandatorySerializerOptions() JsonSerializerSettings.Converters.Insert(0, new MapConverter()); } - private Task DeserializeFromUtf8Stream(System.IO.Stream stream) + private static Task DeserializeFromUtf8Stream( + System.IO.Stream stream, + JsonSerializerSettings serializerSettings + ) { using var sr = new StreamReader(stream); using JsonReader reader = SpeckleObjectSerializerPool.Instance.GetJsonTextReader(sr); - var serializer = JsonSerializer.Create(JsonSerializerSettings); + var serializer = JsonSerializer.Create(serializerSettings); return Task.FromResult(serializer.Deserialize(reader)); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs index 4ae7c597..46b325ad 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs @@ -1,4 +1,5 @@ using Speckle.Sdk.Api; +using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Api.GraphQL.Resources; @@ -31,6 +32,21 @@ public async Task ActiveUserGet_NonAuthed() Assert.That(result, Is.EqualTo(null)); } + [Test] + public async Task ActiveUserUpdate() + { + const string NEW_NAME = "Ron"; + const string NEW_BIO = "Now I have a bio, isn't that nice!"; + const string NEW_COMPANY = "Limited Cooperation Organization Inc"; + var res = await Sut.Update(new UserUpdateInput(name: NEW_NAME, bio: NEW_BIO, company: NEW_COMPANY)); + + Assert.That(res, Is.Not.Null); + Assert.That(res.id, Is.EqualTo(_testUser.Account.userInfo.id)); + Assert.That(res.name, Is.EqualTo(NEW_NAME)); + Assert.That(res.company, Is.EqualTo(NEW_COMPANY)); + Assert.That(res.bio, Is.EqualTo(NEW_BIO)); + } + [Test] public async Task ActiveUserGetProjects() { diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs index 814e4bd8..5fdd554d 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs @@ -21,6 +21,7 @@ public async Task Setup() _model = await _testUser.Model.Create(new("Test Model", "", _project.id)); } + [Order(1)] [TestCase("My Model", "My model description")] [TestCase("my/nested/model", null)] public async Task ModelCreate(string name, string description) @@ -47,6 +48,7 @@ public async Task ModelGet() } [Test] + [Order(2)] public async Task GetModels() { var result = await Sut.GetModels(_project.id); diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs index 0a618d91..ef594ac8 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs @@ -3,6 +3,7 @@ using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Api.GraphQL.Resources; +using Speckle.Sdk.Common; namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources; @@ -27,7 +28,7 @@ private async Task SeedInvite() { ProjectInviteCreateInput input = new(_invitee.Account.userInfo.email, null, null, null); var res = await _inviter.ProjectInvite.Create(_project.id, input); - var invites = await _invitee.ActiveUser.ProjectInvites(); + var invites = await _invitee.ActiveUser.GetProjectInvites(); return invites.First(i => i.projectId == res.id); } @@ -37,12 +38,12 @@ public async Task ProjectInviteCreate_ByEmail() ProjectInviteCreateInput input = new(_invitee.Account.userInfo.email, null, null, null); var res = await _inviter.ProjectInvite.Create(_project.id, input); - var invites = await _invitee.ActiveUser.ProjectInvites(); + var invites = await _invitee.ActiveUser.GetProjectInvites(); var invite = invites.First(i => i.projectId == res.id); Assert.That(res, Has.Property(nameof(_project.id)).EqualTo(_project.id)); Assert.That(res.invitedTeam, Has.Count.EqualTo(1)); - Assert.That(invite.user.id, Is.EqualTo(_invitee.Account.userInfo.id)); + Assert.That(invite.user!.id, Is.EqualTo(_invitee.Account.userInfo.id)); Assert.That(invite.token, Is.Not.Null); } @@ -54,7 +55,7 @@ public async Task ProjectInviteCreate_ByUserId() Assert.That(res, Has.Property(nameof(_project.id)).EqualTo(_project.id)); Assert.That(res.invitedTeam, Has.Count.EqualTo(1)); - Assert.That(res.invitedTeam[0].user.id, Is.EqualTo(_invitee.Account.userInfo.id)); + Assert.That(res.invitedTeam[0].user!.id, Is.EqualTo(_invitee.Account.userInfo.id)); } [Test] @@ -66,13 +67,21 @@ public async Task ProjectInviteGet() collaborator, Has.Property(nameof(PendingStreamCollaborator.inviteId)).EqualTo(_createdInvite.inviteId) ); - Assert.That(collaborator!.user.id, Is.EqualTo(_createdInvite.user.id)); + Assert.That(collaborator!.user!.id, Is.EqualTo(_createdInvite.user!.id)); + } + + [Test] + public async Task ProjectInviteGet_NonExisting() + { + var collaborator = await _invitee.ProjectInvite.Get(_project.id, "this is not a real token"); + + Assert.That(collaborator, Is.Null); } [Test] public async Task ProjectInviteUse_MemberAdded() { - ProjectInviteUseInput input = new(true, _createdInvite.projectId, _createdInvite.token); + ProjectInviteUseInput input = new(true, _createdInvite.projectId, _createdInvite.token.NotNull()); var res = await _invitee.ProjectInvite.Use(input); Assert.That(res, Is.True); @@ -92,10 +101,10 @@ public async Task ProjectInviteCancel_MemberNotAdded() [Test] [TestCase(StreamRoles.STREAM_OWNER)] - [TestCase(StreamRoles.STREAM_REVIEWER)] [TestCase(StreamRoles.STREAM_CONTRIBUTOR)] + [TestCase(StreamRoles.STREAM_REVIEWER)] [TestCase(StreamRoles.REVOKE)] - public async Task ProjectUpdateRole(string newRole) + public async Task ProjectUpdateRole(string? newRole) { await ProjectInviteUse_MemberAdded(); ProjectUpdateRoleInput input = new(_invitee.Account.userInfo.id, _project.id, newRole); diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs index 4cf9ec3b..a52985e2 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs @@ -1,4 +1,5 @@ using Speckle.Sdk.Api; +using Speckle.Sdk.Api.GraphQL.Enums; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Api.GraphQL.Resources; @@ -41,6 +42,8 @@ public async Task UserProjectsUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created.id)); + Assert.That(subscriptionMessage.type, Is.EqualTo(UserProjectsUpdatedMessageType.ADDED)); + Assert.That(subscriptionMessage.project, Is.Not.Null); } [Test] @@ -60,6 +63,8 @@ public async Task ProjectModelsUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created.id)); + Assert.That(subscriptionMessage.type, Is.EqualTo(ProjectModelsUpdatedMessageType.CREATED)); + Assert.That(subscriptionMessage.model, Is.Not.Null); } [Test] @@ -79,6 +84,8 @@ public async Task ProjectUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created.id)); + Assert.That(subscriptionMessage.type, Is.EqualTo(ProjectUpdatedMessageType.UPDATED)); + Assert.That(subscriptionMessage.project, Is.Not.Null); } [Test] @@ -97,6 +104,8 @@ public async Task ProjectVersionsUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created)); + Assert.That(subscriptionMessage.type, Is.EqualTo(ProjectVersionsUpdatedMessageType.CREATED)); + Assert.That(subscriptionMessage.version, Is.Not.Null); } [Test] @@ -116,6 +125,8 @@ public async Task ProjectCommentsUpdated_SubscriptionIsCalled() Assert.That(subscriptionMessage, Is.Not.Null); Assert.That(subscriptionMessage!.id, Is.EqualTo(created.id)); + Assert.That(subscriptionMessage.type, Is.EqualTo(ProjectCommentsUpdatedMessageType.CREATED)); + Assert.That(subscriptionMessage.comment, Is.Not.Null); } [OneTimeTearDown] diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs index 34c2b530..a25badda 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs @@ -26,13 +26,13 @@ public async Task Setup() string versionId = await Fixtures.CreateVersion(_testUser, _project.id, _model1.id); - _version = await Sut.Get(versionId, _model1.id, _project.id); + _version = await Sut.Get(versionId, _project.id); } [Test] public async Task VersionGet() { - Version result = await Sut.Get(_version.id, _model1.id, _project.id); + Version result = await Sut.Get(_version.id, _project.id); Assert.That(result, Has.Property(nameof(Version.id)).EqualTo(_version.id)); Assert.That(result, Has.Property(nameof(Version.message)).EqualTo(_version.message)); @@ -60,7 +60,7 @@ public async Task VersionReceived() [Test] public async Task ModelGetWithVersions() { - Model result = await _testUser.Model.GetWithVersions(_model1.id, _project.id); + var result = await _testUser.Model.GetWithVersions(_model1.id, _project.id); Assert.That(result, Has.Property(nameof(Model.id)).EqualTo(_model1.id)); Assert.That(result.versions.items, Has.Count.EqualTo(1)); @@ -87,13 +87,11 @@ public async Task VersionMoveToModel() MoveVersionsInput input = new(_model2.name, new[] { _version.id }); string id = await Sut.MoveToModel(input); Assert.That(id, Is.EqualTo(_model2.id)); - Version movedVersion = await Sut.Get(_version.id, _model2.id, _project.id); + Version movedVersion = await Sut.Get(_version.id, _project.id); Assert.That(movedVersion, Has.Property(nameof(Version.id)).EqualTo(_version.id)); Assert.That(movedVersion, Has.Property(nameof(Version.message)).EqualTo(_version.message)); Assert.That(movedVersion, Has.Property(nameof(Version.previewUrl)).EqualTo(_version.previewUrl)); - - Assert.CatchAsync(async () => await Sut.Get(id, _model1.id, _project.id)); } [Test] @@ -104,7 +102,7 @@ public async Task VersionDelete() bool response = await Sut.Delete(input); Assert.That(response, Is.True); - Assert.CatchAsync(async () => _ = await Sut.Get(_version.id, _model1.id, _project.id)); + Assert.CatchAsync(async () => _ = await Sut.Get(_version.id, _project.id)); Assert.CatchAsync(async () => _ = await Sut.Delete(input)); } }