From 625fec429476fb59bdf80e36bf8e04c971d5a15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= <57442769+gjedlicska@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:55:40 +0200 Subject: [PATCH] feat(workspaces): leave workspace (#2585) --- .../typedefs/workspaces.graphql | 8 ++ packages/server/codegen.yml | 1 + .../modules/core/graph/generated/graphql.ts | 20 +++++ .../graph/generated/graphql.ts | 11 +++ .../workspaces/graph/resolvers/workspaces.ts | 23 ++++++ .../integration/workspaces.graph.spec.ts | 81 ++++++++++++++++++- .../graph/resolvers/workspacesCore.ts | 5 ++ .../server/test/graphql/generated/graphql.ts | 21 ++++- packages/server/test/graphql/workspaces.ts | 10 +++ 9 files changed, 177 insertions(+), 3 deletions(-) diff --git a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql index 50f75b03a..cb80f6bd7 100644 --- a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql +++ b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql @@ -238,3 +238,11 @@ extend type AdminQueries { input UserWorkspacesFilter { search: String } + +type UserWorkspaceMutations { + leave(id: ID!): Boolean! +} + +extend type ActiveUserMutations { + workspaceMutations: UserWorkspaceMutations +} diff --git a/packages/server/codegen.yml b/packages/server/codegen.yml index a4e1892d8..b45ba1466 100644 --- a/packages/server/codegen.yml +++ b/packages/server/codegen.yml @@ -25,6 +25,7 @@ generates: User: '@/modules/core/helpers/graphTypes#UserGraphQLReturn' ActiveUserMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' UserEmailMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' + UserWorkspaceMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' ProjectMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' ProjectInviteMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' ModelMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn' diff --git a/packages/server/modules/core/graph/generated/graphql.ts b/packages/server/modules/core/graph/generated/graphql.ts index 118098589..8fde4da2c 100644 --- a/packages/server/modules/core/graph/generated/graphql.ts +++ b/packages/server/modules/core/graph/generated/graphql.ts @@ -38,6 +38,7 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; + workspaceMutations?: Maybe; }; @@ -3576,6 +3577,16 @@ 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; }; @@ -4230,6 +4241,7 @@ export type ResolversTypes = { UserRoleInput: UserRoleInput; UserSearchResultCollection: ResolverTypeWrapper & { items: Array }>; UserUpdateInput: UserUpdateInput; + UserWorkspaceMutations: ResolverTypeWrapper; UserWorkspacesFilter: UserWorkspacesFilter; Version: ResolverTypeWrapper; VersionCollection: ResolverTypeWrapper & { items: Array }>; @@ -4453,6 +4465,7 @@ export type ResolversParentTypes = { UserRoleInput: UserRoleInput; UserSearchResultCollection: Omit & { items: Array }; UserUpdateInput: UserUpdateInput; + UserWorkspaceMutations: MutationsObjectGraphQLReturn; UserWorkspacesFilter: UserWorkspacesFilter; Version: VersionGraphQLReturn; VersionCollection: Omit & { items: Array }; @@ -4524,6 +4537,7 @@ export type ActiveUserMutationsResolvers; finishOnboarding?: Resolver; update?: Resolver>; + workspaceMutations?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }; @@ -5691,6 +5705,11 @@ export type UserSearchResultCollectionResolvers; }; +export type UserWorkspaceMutationsResolvers = { + leave?: Resolver>; + __isTypeOf?: IsTypeOfResolverFn; +}; + export type VersionResolvers = { authorUser?: Resolver, ParentType, ContextType>; automationsStatus?: Resolver, ParentType, ContextType>; @@ -5957,6 +5976,7 @@ 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 9262ca964..7267e805d 100644 --- a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts +++ b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts @@ -27,6 +27,7 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; + workspaceMutations?: Maybe; }; @@ -3565,6 +3566,16 @@ 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; }; diff --git a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts index b316e1e85..dcc613516 100644 --- a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts +++ b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts @@ -514,6 +514,29 @@ 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/workspaces/tests/integration/workspaces.graph.spec.ts b/packages/server/modules/workspaces/tests/integration/workspaces.graph.spec.ts index c846ab7f2..5a7f5dd49 100644 --- a/packages/server/modules/workspaces/tests/integration/workspaces.graph.spec.ts +++ b/packages/server/modules/workspaces/tests/integration/workspaces.graph.spec.ts @@ -15,7 +15,9 @@ import { CreateWorkspaceDocument, GetActiveUserWorkspacesDocument, GetWorkspaceDocument, - UpdateWorkspaceDocument + UpdateWorkspaceDocument, + ActiveUserLeaveWorkspaceDocument, + UpdateWorkspaceRoleDocument } from '@/test/graphql/generated/graphql' import { Workspace } from '@/modules/workspacesCore/domain/types' import { beforeEachContext } from '@/test/hooks' @@ -35,9 +37,17 @@ describe('Workspaces GQL CRUD', () => { role: Roles.Server.Admin } + const userB: BasicTestUser = { + id: '', + name: 'Alice speckle', + email: 'alice-speckle@example.org', + role: Roles.Server.User + } + before(async () => { await beforeEachContext() - await createTestUser(testUser) + await Promise.all([createTestUser(testUser), createTestUser(userB)]) + const token = await createAuthTokenForUser(testUser.id, AllScopes) apollo = await testApolloServer({ context: createTestContext({ @@ -179,5 +189,72 @@ describe('Workspaces GQL CRUD', () => { expect(data?.workspace.description).to.equal('') }) }) + describe('mutation activeUserMutations.userWorkspaceMutations', () => { + describe('leave', () => { + it('allows the active user to leave a workspace', async () => { + const name = cryptoRandomString({ length: 6 }) + const workspaceCreateResult = await apollo.execute(CreateWorkspaceDocument, { + input: { name } + }) + + const id = workspaceCreateResult.data?.workspaceMutations.create.id + if (!id) throw new Error('This should have succeeded') + + await apollo.execute(UpdateWorkspaceRoleDocument, { + input: { + userId: userB.id, + workspaceId: id, + role: Roles.Workspace.Admin + } + }) + + let userWorkspaces = await apollo.execute(GetActiveUserWorkspacesDocument, {}) + + expect( + userWorkspaces.data?.activeUser?.workspaces.items + .map((i) => i.name) + .includes(name) + ).to.be.true + + const leaveResult = await apollo.execute(ActiveUserLeaveWorkspaceDocument, { + id + }) + + expect(leaveResult.errors).to.be.undefined + + userWorkspaces = await apollo.execute(GetActiveUserWorkspacesDocument, {}) + expect( + userWorkspaces.data?.activeUser?.workspaces.items + .map((i) => i.name) + .includes(name) + ).to.be.false + }) + it('stops the last workspace admin from leaving the workspace', async () => { + const name = cryptoRandomString({ length: 6 }) + const workspaceCreateResult = await apollo.execute(CreateWorkspaceDocument, { + input: { name } + }) + + const id = workspaceCreateResult.data?.workspaceMutations.create.id + if (!id) throw new Error('This should have succeeded') + + const leaveResult = await apollo.execute(ActiveUserLeaveWorkspaceDocument, { + id + }) + + expect(leaveResult.errors?.length).to.be.greaterThanOrEqual(1) + + const userWorkspaces = await apollo.execute( + GetActiveUserWorkspacesDocument, + {} + ) + expect( + userWorkspaces.data?.activeUser?.workspaces.items + .map((i) => i.name) + .includes(name) + ).to.be.true + }) + }) + }) }) }) diff --git a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts index 3402add81..91de9c64c 100644 --- a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts +++ b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts @@ -71,6 +71,11 @@ 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 aa8e68b3d..dbd8cc0c9 100644 --- a/packages/server/test/graphql/generated/graphql.ts +++ b/packages/server/test/graphql/generated/graphql.ts @@ -28,6 +28,7 @@ export type ActiveUserMutations = { finishOnboarding: Scalars['Boolean']['output']; /** Edit a user's profile */ update: User; + workspaceMutations?: Maybe; }; @@ -3566,6 +3567,16 @@ 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; }; @@ -4568,6 +4579,13 @@ export type GetWorkspaceProjectsQueryVariables = Exact<{ export type GetWorkspaceProjectsQuery = { __typename?: 'Query', workspace: { __typename?: 'Workspace', projects: { __typename?: 'ProjectCollection', cursor?: string | null, totalCount: number, items: Array<{ __typename?: 'Project', id: string, name: string, createdAt: string, updatedAt: string }> } } }; +export type ActiveUserLeaveWorkspaceMutationVariables = Exact<{ + id: Scalars['ID']['input']; +}>; + + +export type ActiveUserLeaveWorkspaceMutation = { __typename?: 'Mutation', activeUserMutations: { __typename?: 'ActiveUserMutations', workspaceMutations?: { __typename?: 'UserWorkspaceMutations', leave: boolean } | null } }; + 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; export const BasicStreamAccessRequestFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BasicStreamAccessRequestFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"StreamAccessRequest"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"requester"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"requesterId"}},{"kind":"Field","name":{"kind":"Name","value":"streamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]} as unknown as DocumentNode; @@ -4665,4 +4683,5 @@ export const UpdateWorkspaceDocument = {"kind":"Document","definitions":[{"kind" export const GetActiveUserWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActiveUserWorkspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeUser"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TestWorkspace"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TestWorkspace"},"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":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"logo"}}]}}]} as unknown as DocumentNode; export const UpdateWorkspaceRoleDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspaceRole"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceRoleUpdateInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceMutations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateRole"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"team"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"role"}}]}}]}}]}}]}}]} as unknown as DocumentNode; 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; \ No newline at end of file +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 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 diff --git a/packages/server/test/graphql/workspaces.ts b/packages/server/test/graphql/workspaces.ts index 1b4f7ff72..6c02fbe29 100644 --- a/packages/server/test/graphql/workspaces.ts +++ b/packages/server/test/graphql/workspaces.ts @@ -118,3 +118,13 @@ export const getWorkspaceProjects = gql` } ${workspaceProjectFragment} ` + +export const leaveWorkspaceMutation = gql` + mutation ActiveUserLeaveWorkspace($id: ID!) { + activeUserMutations { + workspaceMutations { + leave(id: $id) + } + } + } +`