diff --git a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql index 1a61d3758..82c10cb22 100644 --- a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql +++ b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql @@ -87,6 +87,7 @@ type WorkspaceMutations { update(input: WorkspaceUpdateInput!): Workspace! @hasScope(scope: "workspace:update") updateRole(input: WorkspaceRoleUpdateInput!): Workspace! @hasScope(scope: "workspace:update") + leave(id: ID!): Boolean! invites: WorkspaceInviteMutations! } @@ -260,11 +261,3 @@ extend type AdminQueries { input UserWorkspacesFilter { search: String } - -type UserWorkspaceMutations { - leave(id: ID!): Boolean! -} - -extend type ActiveUserMutations { - workspaceMutations: UserWorkspaceMutations -} diff --git a/packages/server/modules/core/graph/generated/graphql.ts b/packages/server/modules/core/graph/generated/graphql.ts index 58ee328fc..6575ca2dd 100644 --- a/packages/server/modules/core/graph/generated/graphql.ts +++ b/packages/server/modules/core/graph/generated/graphql.ts @@ -38,7 +38,6 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; - workspaceMutations?: Maybe; }; @@ -3592,16 +3591,6 @@ export type UserUpdateInput = { name?: InputMaybe; }; -export type UserWorkspaceMutations = { - __typename?: 'UserWorkspaceMutations'; - leave: Scalars['Boolean']['output']; -}; - - -export type UserWorkspaceMutationsLeaveArgs = { - id: Scalars['ID']['input']; -}; - export type UserWorkspacesFilter = { search?: InputMaybe; }; @@ -3923,6 +3912,7 @@ export type WorkspaceMutations = { create: Workspace; delete: Scalars['Boolean']['output']; invites: WorkspaceInviteMutations; + leave: Scalars['Boolean']['output']; update: Workspace; updateRole: Workspace; }; @@ -3938,6 +3928,11 @@ export type WorkspaceMutationsDeleteArgs = { }; +export type WorkspaceMutationsLeaveArgs = { + id: Scalars['ID']['input']; +}; + + export type WorkspaceMutationsUpdateArgs = { input: WorkspaceUpdateInput; }; @@ -4277,7 +4272,6 @@ export type ResolversTypes = { UserRoleInput: UserRoleInput; UserSearchResultCollection: ResolverTypeWrapper & { items: Array }>; UserUpdateInput: UserUpdateInput; - UserWorkspaceMutations: ResolverTypeWrapper; UserWorkspacesFilter: UserWorkspacesFilter; Version: ResolverTypeWrapper; VersionCollection: ResolverTypeWrapper & { items: Array }>; @@ -4504,7 +4498,6 @@ export type ResolversParentTypes = { UserRoleInput: UserRoleInput; UserSearchResultCollection: Omit & { items: Array }; UserUpdateInput: UserUpdateInput; - UserWorkspaceMutations: MutationsObjectGraphQLReturn; UserWorkspacesFilter: UserWorkspacesFilter; Version: VersionGraphQLReturn; VersionCollection: Omit & { items: Array }; @@ -4577,7 +4570,6 @@ export type ActiveUserMutationsResolvers; finishOnboarding?: Resolver; update?: Resolver>; - workspaceMutations?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }; @@ -5747,11 +5739,6 @@ export type UserSearchResultCollectionResolvers; }; -export type UserWorkspaceMutationsResolvers = { - leave?: Resolver>; - __isTypeOf?: IsTypeOfResolverFn; -}; - export type VersionResolvers = { authorUser?: Resolver, ParentType, ContextType>; automationsStatus?: Resolver, ParentType, ContextType>; @@ -5899,6 +5886,7 @@ export type WorkspaceMutationsResolvers>; delete?: Resolver>; invites?: Resolver; + leave?: Resolver>; update?: Resolver>; updateRole?: Resolver>; __isTypeOf?: IsTypeOfResolverFn; @@ -6018,7 +6006,6 @@ export type Resolvers = { UserEmailMutations?: UserEmailMutationsResolvers; UserProjectsUpdatedMessage?: UserProjectsUpdatedMessageResolvers; UserSearchResultCollection?: UserSearchResultCollectionResolvers; - UserWorkspaceMutations?: UserWorkspaceMutationsResolvers; Version?: VersionResolvers; VersionCollection?: VersionCollectionResolvers; VersionCreatedTrigger?: VersionCreatedTriggerResolvers; diff --git a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts index 45d801472..847d59d64 100644 --- a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts +++ b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts @@ -27,7 +27,6 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; - workspaceMutations?: Maybe; }; @@ -3581,16 +3580,6 @@ export type UserUpdateInput = { name?: InputMaybe; }; -export type UserWorkspaceMutations = { - __typename?: 'UserWorkspaceMutations'; - leave: Scalars['Boolean']['output']; -}; - - -export type UserWorkspaceMutationsLeaveArgs = { - id: Scalars['ID']['input']; -}; - export type UserWorkspacesFilter = { search?: InputMaybe; }; @@ -3912,6 +3901,7 @@ export type WorkspaceMutations = { create: Workspace; delete: Scalars['Boolean']['output']; invites: WorkspaceInviteMutations; + leave: Scalars['Boolean']['output']; update: Workspace; updateRole: Workspace; }; @@ -3927,6 +3917,11 @@ export type WorkspaceMutationsDeleteArgs = { }; +export type WorkspaceMutationsLeaveArgs = { + id: Scalars['ID']['input']; +}; + + export type WorkspaceMutationsUpdateArgs = { input: WorkspaceUpdateInput; }; diff --git a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts index 2d2113eeb..7dc170885 100644 --- a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts +++ b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts @@ -312,6 +312,24 @@ export = FF_WORKSPACES_MODULE_ENABLED return await getWorkspaceFactory({ db })({ workspaceId }) }, + leave: async (_parent, args, ctx) => { + const userId = ctx.userId! + + const getWorkspaceRoles = getWorkspaceRolesFactory({ db }) + const emitWorkspaceEvent = getEventBus().emit + + const deleteWorkspaceRole = deleteWorkspaceRoleFactory({ + deleteWorkspaceRole: repoDeleteWorkspaceRoleFactory({ db }), + getWorkspaceRoles, + emitWorkspaceEvent, + getStreams, + revokeStreamPermissions + }) + + await deleteWorkspaceRole({ workspaceId: args.id, userId }) + + return true + }, invites: () => ({}) }, WorkspaceInviteMutations: { @@ -540,29 +558,6 @@ export = FF_WORKSPACES_MODULE_ENABLED workspaceList: async () => { throw new WorkspacesNotYetImplementedError() } - }, - ActiveUserMutations: { - workspaceMutations: () => ({}) - }, - UserWorkspaceMutations: { - leave: async (parent, args, ctx) => { - const userId = ctx.userId! - - const getWorkspaceRoles = getWorkspaceRolesFactory({ db }) - const emitWorkspaceEvent = getEventBus().emit - - const deleteWorkspaceRole = deleteWorkspaceRoleFactory({ - deleteWorkspaceRole: repoDeleteWorkspaceRoleFactory({ db }), - getWorkspaceRoles, - emitWorkspaceEvent, - getStreams, - revokeStreamPermissions - }) - - await deleteWorkspaceRole({ workspaceId: args.id, userId }) - - return true - } } } as Resolvers) : {} diff --git a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts index 91de9c64c..2f1d5dc79 100644 --- a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts +++ b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts @@ -27,6 +27,9 @@ export = !FF_WORKSPACES_MODULE_ENABLED updateRole: async () => { throw new WorkspacesModuleDisabledError() }, + leave: async () => { + throw new WorkspacesModuleDisabledError() + }, invites: () => ({}) }, WorkspaceInviteMutations: { @@ -71,11 +74,6 @@ export = !FF_WORKSPACES_MODULE_ENABLED workspaceList: async () => { throw new WorkspacesModuleDisabledError() } - }, - ActiveUserMutations: { - workspaceMutations: async () => { - throw new WorkspacesModuleDisabledError() - } } } as Resolvers) : {} diff --git a/packages/server/test/graphql/generated/graphql.ts b/packages/server/test/graphql/generated/graphql.ts index 0ae698017..707b99a4a 100644 --- a/packages/server/test/graphql/generated/graphql.ts +++ b/packages/server/test/graphql/generated/graphql.ts @@ -28,7 +28,6 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; - workspaceMutations?: Maybe; }; @@ -3582,16 +3581,6 @@ export type UserUpdateInput = { name?: InputMaybe; }; -export type UserWorkspaceMutations = { - __typename?: 'UserWorkspaceMutations'; - leave: Scalars['Boolean']['output']; -}; - - -export type UserWorkspaceMutationsLeaveArgs = { - id: Scalars['ID']['input']; -}; - export type UserWorkspacesFilter = { search?: InputMaybe; }; @@ -3913,6 +3902,7 @@ export type WorkspaceMutations = { create: Workspace; delete: Scalars['Boolean']['output']; invites: WorkspaceInviteMutations; + leave: Scalars['Boolean']['output']; update: Workspace; updateRole: Workspace; }; @@ -3928,6 +3918,11 @@ export type WorkspaceMutationsDeleteArgs = { }; +export type WorkspaceMutationsLeaveArgs = { + id: Scalars['ID']['input']; +}; + + export type WorkspaceMutationsUpdateArgs = { input: WorkspaceUpdateInput; }; @@ -4635,7 +4630,7 @@ export type ActiveUserLeaveWorkspaceMutationVariables = Exact<{ }>; -export type ActiveUserLeaveWorkspaceMutation = { __typename?: 'Mutation', activeUserMutations: { __typename?: 'ActiveUserMutations', workspaceMutations?: { __typename?: 'UserWorkspaceMutations', leave: boolean } | null } }; +export type ActiveUserLeaveWorkspaceMutation = { __typename?: 'Mutation', workspaceMutations: { __typename?: 'WorkspaceMutations', leave: boolean } }; export const BasicWorkspaceFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BasicWorkspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"role"}}]}}]} as unknown as DocumentNode; export const BasicPendingWorkspaceCollaboratorFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BasicPendingWorkspaceCollaborator"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"PendingWorkspaceCollaborator"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"inviteId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceName"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"invitedBy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]} as unknown as DocumentNode; @@ -4738,4 +4733,4 @@ export const UpdateWorkspaceRoleDocument = {"kind":"Document","definitions":[{"k export const CreateWorkspaceProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateWorkspaceProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ProjectCreateInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"projectMutations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"create"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TestWorkspaceProject"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TestWorkspaceProject"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode; export const GetWorkspaceProjectsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceProjects"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cursor"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceProjectsFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"projects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"cursor"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cursor"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TestWorkspaceProject"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cursor"}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TestWorkspaceProject"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode; export const GetWorkspaceTeamDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceTeam"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceTeamFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"team"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TestWorkspaceCollaborator"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TestWorkspaceCollaborator"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceCollaborator"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"role"}}]}}]} as unknown as DocumentNode; -export const ActiveUserLeaveWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ActiveUserLeaveWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeUserMutations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceMutations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"leave"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const ActiveUserLeaveWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ActiveUserLeaveWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceMutations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"leave"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/server/test/graphql/workspaces.ts b/packages/server/test/graphql/workspaces.ts index 158443de0..0ffe39bce 100644 --- a/packages/server/test/graphql/workspaces.ts +++ b/packages/server/test/graphql/workspaces.ts @@ -147,10 +147,8 @@ export const getWorkspaceTeamQuery = gql` export const leaveWorkspaceMutation = gql` mutation ActiveUserLeaveWorkspace($id: ID!) { - activeUserMutations { - workspaceMutations { - leave(id: $id) - } + workspaceMutations { + leave(id: $id) } } `