diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/CreateUserWithPasswordSelectOAuthConnections.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/CreateUserWithPasswordSelectOAuthConnections.graphql index 86874a4834..34e7f2aa6e 100644 --- a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/CreateUserWithPasswordSelectOAuthConnections.graphql +++ b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/CreateUserWithPasswordSelectOAuthConnections.graphql @@ -4,8 +4,10 @@ mutation CreateUserWithPasswordSelectOAuthConnections($name: String!, $password: id user { oAuthConnections { - externalUserId - provider + nodes { + externalUserId + provider + } } } } diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/SetUserOAuthConnections.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/SetUserOAuthConnections.graphql index 34f74f64bf..497a609f31 100644 --- a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/SetUserOAuthConnections.graphql +++ b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/SetUserOAuthConnections.graphql @@ -11,8 +11,10 @@ mutation SetUserOAuthConnections($id: ID!, $newOAuthConnections: [OAuthConnectio name systemIdentifier oAuthConnections { - externalUserId - provider + nodes { + externalUserId + provider + } } } } diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/UpdateUserOAuthConnections.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/UpdateUserOAuthConnections.graphql index ad0fdfdbad..d4697c6880 100644 --- a/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/UpdateUserOAuthConnections.graphql +++ b/src/Tgstation.Server.Client.GraphQL/GQL/Mutations/UpdateUserOAuthConnections.graphql @@ -4,8 +4,10 @@ mutation UpdateUserOAuthConnections($id: ID!, $newOAuthConnections: [OAuthConnec id user { oAuthConnections { - externalUserId - provider + nodes { + externalUserId + provider + } } } } diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/GetSomeGroupInfo.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/GetSomeGroupInfo.graphql index 6ed50da05f..7ffa24a9e3 100644 --- a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/GetSomeGroupInfo.graphql +++ b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/GetSomeGroupInfo.graphql @@ -27,7 +27,7 @@ query GetSomeGroupInfo($id: ID!) { canWriteUsers } } - queryableUsersByGroup(first: 1) { + users(first: 1) { totalCount nodes { id diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql index 79dfa3e5ef..7bff284c25 100644 --- a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql +++ b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql @@ -13,8 +13,10 @@ query ReadCurrentUser { name } oAuthConnections { - externalUserId - provider + nodes { + externalUserId + provider + } } effectivePermissionSet { administrationRights { diff --git a/src/Tgstation.Server.Host/Authority/IUserAuthority.cs b/src/Tgstation.Server.Host/Authority/IUserAuthority.cs index 26c7ee0846..4bb1fa17eb 100644 --- a/src/Tgstation.Server.Host/Authority/IUserAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/IUserAuthority.cs @@ -42,20 +42,20 @@ namespace Tgstation.Server.Host.Authority where TResult : class; /// - /// Gets the s for the with a given . + /// Gets the s for the with a given . /// /// The of the . /// The for the operation. - /// A of . - RequirementsGated> OAuthConnections(long userId, CancellationToken cancellationToken); + /// A of . + RequirementsGated> OAuthConnections(long userId, CancellationToken cancellationToken); /// - /// Gets the s for the with a given . + /// Gets the s for the with a given . /// /// The of the . /// The for the operation. - /// A of . - RequirementsGated> OidcConnections(long userId, CancellationToken cancellationToken); + /// A of . + RequirementsGated> OidcConnections(long userId, CancellationToken cancellationToken); /// /// Gets all registered s. diff --git a/src/Tgstation.Server.Host/Authority/UserAuthority.cs b/src/Tgstation.Server.Host/Authority/UserAuthority.cs index 1022e79e28..f3f1037868 100644 --- a/src/Tgstation.Server.Host/Authority/UserAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/UserAuthority.cs @@ -333,22 +333,24 @@ namespace Tgstation.Server.Host.Authority () => ValueTask.FromResult(Queryable(includeJoins, false))); /// - public RequirementsGated> OAuthConnections(long userId, CancellationToken cancellationToken) + public RequirementsGated> OAuthConnections(long userId, CancellationToken cancellationToken) => new( () => claimsPrincipalAccessor.User.GetTgsUserId() != userId ? Flag(AdministrationRights.ReadUsers) : null, - async () => new AuthorityResponse( - await oAuthConnectionsDataLoader.LoadRequiredAsync(userId, cancellationToken))); + () => Queryable(true, true) + .SelectMany(user => user.OAuthConnections!) + .TagWith("Get User OAuthConnections")); /// - public RequirementsGated> OidcConnections(long userId, CancellationToken cancellationToken) + public RequirementsGated> OidcConnections(long userId, CancellationToken cancellationToken) => new( () => claimsPrincipalAccessor.User.GetTgsUserId() != userId ? Flag(AdministrationRights.ReadUsers) : null, - async () => new AuthorityResponse( - await oidcConnectionsDataLoader.LoadRequiredAsync(userId, cancellationToken))); + () => Queryable(true, true) + .SelectMany(user => user.OidcConnections!) + .TagWith("Get User OIdcConnections")); /// #pragma warning disable CA1506 // TODO: Decomplexify diff --git a/src/Tgstation.Server.Host/GraphQL/Types/User.cs b/src/Tgstation.Server.Host/GraphQL/Types/User.cs index bb4015733f..9080743b78 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/User.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/User.cs @@ -65,7 +65,7 @@ namespace Tgstation.Server.Host.GraphQL.Types /// public required PermissionSet EffectivePermissionSet { get; set; } - /// + /// /// The for the user if the user does not belong to a . /// public required PermissionSet? OwnedPermissionSet { get; set; } @@ -145,12 +145,16 @@ namespace Tgstation.Server.Host.GraphQL.Types /// The for the . /// The for the operation. /// A resulting in a new of s for the if OAuth is configured. - public ValueTask OAuthConnections( + [UsePaging] + [UseProjection] + [UseFiltering] + [UseSorting] + public ValueTask> OAuthConnections( [Service] IGraphQLAuthorityInvoker userAuthority, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.Invoke( + return userAuthority.InvokeTransformableQueryable( authority => authority.OAuthConnections(Id, cancellationToken)); } @@ -160,12 +164,16 @@ namespace Tgstation.Server.Host.GraphQL.Types /// The for the . /// The for the operation. /// A resulting in a new of s for the if OAuth is configured. - public ValueTask OidcConnections( + [UsePaging] + [UseProjection] + [UseFiltering] + [UseSorting] + public ValueTask> OidcConnections( [Service] IGraphQLAuthorityInvoker userAuthority, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.Invoke( + return userAuthority.InvokeTransformableQueryable( authority => authority.OidcConnections(Id, cancellationToken)); } } diff --git a/tests/Tgstation.Server.Tests/Live/UsersTest.cs b/tests/Tgstation.Server.Tests/Live/UsersTest.cs index bd8d4f9248..56cb11529a 100644 --- a/tests/Tgstation.Server.Tests/Live/UsersTest.cs +++ b/tests/Tgstation.Server.Tests/Live/UsersTest.cs @@ -308,9 +308,9 @@ namespace Tgstation.Server.Tests.Live var testUser = testUserResult2.UpdatedUser.User; Assert.IsNotNull(testUser.OAuthConnections); - Assert.AreEqual(1, testUser.OAuthConnections.Count); - Assert.AreEqual(sampleOAuthConnections.First().ExternalUserId, testUser.OAuthConnections[0].ExternalUserId); - Assert.AreEqual(sampleOAuthConnections.First().Provider, testUser.OAuthConnections[0].Provider); + Assert.AreEqual(1, testUser.OAuthConnections.Nodes.Count); + Assert.AreEqual(sampleOAuthConnections.First().ExternalUserId, testUser.OAuthConnections.Nodes[0].ExternalUserId); + Assert.AreEqual(sampleOAuthConnections.First().Provider, testUser.OAuthConnections.Nodes[0].Provider); var groupResult = await client.RunMutationEnsureNoErrors( gql => gql.CreateUserGroup.ExecuteAsync("TestGroup", cancellationToken), @@ -471,9 +471,9 @@ namespace Tgstation.Server.Tests.Live cancellationToken); var group4 = group4Result.Swarm.UserGroups.ById; - Assert.IsNotNull(group4.QueryableUsersByGroup.Nodes); - Assert.AreEqual(1, group4.QueryableUsersByGroup.TotalCount); - Assert.AreEqual(testUser2.Id, group4.QueryableUsersByGroup.Nodes[0].Id); + Assert.IsNotNull(group4.Users.Nodes); + Assert.AreEqual(1, group4.Users.TotalCount); + Assert.AreEqual(testUser2.Id, group4.Users.Nodes[0].Id); Assert.IsNotNull(group4.PermissionSet); var testUser4Result = await client.RunMutationEnsureNoErrors(