feat: add getSharedConnectionRoleIds query
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import Context from '../../types/express/context';
|
||||
import Connection from '../../models/connection';
|
||||
|
||||
type Params = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const getSharedConnectionRoleIds = async (
|
||||
_parent: unknown,
|
||||
params: Params,
|
||||
context: Context
|
||||
) => {
|
||||
const conditions = context.currentUser.can('update', 'Connection');
|
||||
|
||||
if (conditions.isCreator) return;
|
||||
|
||||
const connection = await Connection
|
||||
.query()
|
||||
.findById(params.id)
|
||||
.throwIfNotFound();
|
||||
|
||||
const sharedConnections = await connection.$relatedQuery('sharedConnections');
|
||||
|
||||
const roleIds = sharedConnections.map(({ roleId }) => roleId);
|
||||
|
||||
return roleIds;
|
||||
};
|
||||
|
||||
export default getSharedConnectionRoleIds;
|
@@ -24,6 +24,7 @@ import getRole from './queries/get-role.ee';
|
||||
import getRoles from './queries/get-roles.ee';
|
||||
import getSamlAuthProviderRoleMappings from './queries/get-saml-auth-provider-role-mappings.ee';
|
||||
import getSamlAuthProvider from './queries/get-saml-auth-provider.ee';
|
||||
import getSharedConnectionRoleIds from './queries/get-shared-connection-role-ids.ee';
|
||||
import getStepWithTestExecutions from './queries/get-step-with-test-executions';
|
||||
import getSubscriptionStatus from './queries/get-subscription-status.ee';
|
||||
import getTrialStatus from './queries/get-trial-status.ee';
|
||||
@@ -60,6 +61,7 @@ const queryResolvers = {
|
||||
getRoles,
|
||||
getSamlAuthProvider,
|
||||
getSamlAuthProviderRoleMappings,
|
||||
getSharedConnectionRoleIds,
|
||||
getStepWithTestExecutions,
|
||||
getSubscriptionStatus,
|
||||
getTrialStatus,
|
||||
|
@@ -53,6 +53,7 @@ type Query {
|
||||
getNotifications: [Notification]
|
||||
getSamlAuthProvider: SamlAuthProvider
|
||||
getSamlAuthProviderRoleMappings(id: String!): [SamlAuthProvidersRoleMapping]
|
||||
getSharedConnectionRoleIds(id: String!): [String]
|
||||
getSubscriptionStatus: GetSubscriptionStatus
|
||||
getTrialStatus: GetTrialStatus
|
||||
getUser(id: String!): User
|
||||
|
Reference in New Issue
Block a user