ede566eed9
* prep for new resources algo * typescriptifying stuff * minor types fix * migrate to resources col * repo & creation updated, WIP processing/retrieval * WIP invite processing * finished finalization refactor * project invite management * transformed all invites services * fixed up projects & core serverinvites resolvers * test fixes * WIP workspace create GQL & test * basic invite creation test works * a buncha working tests * more tests * cancelation tests * minor invite use refactor * invite retrieval tasks * invite use() works as expected * filtering out broken invites * enabled invite retrieval by token irregardless of who is it for * minor adjustments * tests fix * test config improvements * test env adjustment * extra test case * making resource access limits harder to ignore * linter fixes * eventBus type cleanup * better generic names * refactored serverinvites resource migration * fix(server): better error message in project invite edge case
147 lines
3.1 KiB
TypeScript
147 lines
3.1 KiB
TypeScript
import { gql } from 'apollo-server-express'
|
|
|
|
export const basicWorkspaceFragment = gql`
|
|
fragment BasicWorkspace on Workspace {
|
|
id
|
|
name
|
|
updatedAt
|
|
createdAt
|
|
role
|
|
}
|
|
`
|
|
|
|
export const basicPendingWorkspaceCollaboratorFragment = gql`
|
|
fragment BasicPendingWorkspaceCollaborator on PendingWorkspaceCollaborator {
|
|
id
|
|
inviteId
|
|
workspaceId
|
|
workspaceName
|
|
title
|
|
role
|
|
invitedBy {
|
|
id
|
|
name
|
|
}
|
|
user {
|
|
id
|
|
name
|
|
}
|
|
token
|
|
}
|
|
`
|
|
|
|
export const createWorkspaceInviteQuery = gql`
|
|
mutation CreateWorkspaceInvite(
|
|
$workspaceId: String!
|
|
$input: WorkspaceInviteCreateInput!
|
|
) {
|
|
workspaceMutations {
|
|
invites {
|
|
create(workspaceId: $workspaceId, input: $input) {
|
|
...BasicWorkspace
|
|
invitedTeam {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
${basicWorkspaceFragment}
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
|
|
export const batchCreateWorkspaceInvitesQuery = gql`
|
|
mutation BatchCreateWorkspaceInvites(
|
|
$workspaceId: String!
|
|
$input: [WorkspaceInviteCreateInput!]!
|
|
) {
|
|
workspaceMutations {
|
|
invites {
|
|
batchCreate(workspaceId: $workspaceId, input: $input) {
|
|
...BasicWorkspace
|
|
invitedTeam {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
${basicWorkspaceFragment}
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
|
|
export const getWorkspaceWithTeamQuery = gql`
|
|
query GetWorkspaceWithTeam($workspaceId: String!) {
|
|
workspace(id: $workspaceId) {
|
|
...BasicWorkspace
|
|
invitedTeam {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
}
|
|
|
|
${basicWorkspaceFragment}
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
|
|
export const cancelInviteMutation = gql`
|
|
mutation CancelWorkspaceInvite($workspaceId: String!, $inviteId: String!) {
|
|
workspaceMutations {
|
|
invites {
|
|
cancel(workspaceId: $workspaceId, inviteId: $inviteId) {
|
|
...BasicWorkspace
|
|
invitedTeam {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
${basicWorkspaceFragment}
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
export const useInviteMutation = gql`
|
|
mutation UseWorkspaceInvite($input: WorkspaceInviteUseInput!) {
|
|
workspaceMutations {
|
|
invites {
|
|
use(input: $input)
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
export const getWorkspaceInviteQuery = gql`
|
|
query GetWorkspaceInvite($workspaceId: String!, $token: String) {
|
|
workspaceInvite(workspaceId: $workspaceId, token: $token) {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
|
|
export const getMyWorkspaceInvitesQuery = gql`
|
|
query GetMyWorkspaceInvites {
|
|
activeUser {
|
|
workspaceInvites {
|
|
...BasicPendingWorkspaceCollaborator
|
|
}
|
|
}
|
|
}
|
|
|
|
${basicPendingWorkspaceCollaboratorFragment}
|
|
`
|
|
|
|
export const createWorkspaceProjectInviteMutation = gql`
|
|
mutation UseWorkspaceProjectInvite($input: ProjectInviteUseInput!) {
|
|
projectMutations {
|
|
invites {
|
|
use(input: $input)
|
|
}
|
|
}
|
|
}
|
|
`
|