Skip to content

Commit

Permalink
feat(workspaces): stencil gql resolvers (#2508)
Browse files Browse the repository at this point in the history
* feat(workspaces): stencil gql resolvers

* fix(workspaces): lol lmao

* feat(workspaces): stencil gql api and resolvers

* fix(workspaces): roles and scopes

* fix(workspaces): add scopes
  • Loading branch information
cdriesler authored Jul 19, 2024
1 parent 07f0ed2 commit 27179ad
Show file tree
Hide file tree
Showing 10 changed files with 1,067 additions and 93 deletions.
90 changes: 0 additions & 90 deletions packages/server/assets/workspaces/workspaces.graphql

This file was deleted.

176 changes: 176 additions & 0 deletions packages/server/assets/workspacesCore/typedefs/workspaces.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
extend type Query {
workspace(id: String!): Workspace! @hasScope(scope: "workspace:read")
}

input WorkspaceCreateInput {
name: String!
description: String
logoUrl: String
}

input WorkspaceUpdateInput {
id: String!
name: String
description: String
logoUrl: String
}

input WorkspaceRoleUpdateInput {
userId: String!
workspaceId: String!
role: WorkspaceRole!
}

input WorkspaceRoleDeleteInput {
userId: String!
workspaceId: String!
}

extend type Mutation {
workspaceMutations: WorkspaceMutations! @hasServerRole(role: SERVER_USER)
}

type WorkspaceMutations {
create(input: WorkspaceCreateInput!): Workspace! @hasScope(scope: "workspace:create")
delete(workspaceId: String!): Workspace! @hasScope(scope: "workspace:delete")
update(input: WorkspaceUpdateInput!): Workspace! @hasScope(scope: "workspace:update")
"""
TODO: `@hasWorkspaceRole(role: WORKSPACE_ADMIN)` for role changes
"""
updateRole(input: WorkspaceRoleUpdateInput!): Boolean!
@hasScope(scope: "workspace:update")
deleteRole(input: WorkspaceRoleDeleteInput!): Boolean!
@hasScope(scope: "workspace:update")
invites: WorkspaceInviteMutations!
}

input WorkspaceInviteCreateInput {
"""
Either this or userId must be filled
"""
email: String
"""
Either this or email must be filled
"""
userId: String
"""
Defaults to the member role, if not specified
"""
role: WorkspaceRole
}

input WorkspaceInviteUseInput {
workspaceId: String!
token: String!
accept: Boolean!
}

type WorkspaceInviteMutations {
create(workspaceId: String!, input: WorkspaceInviteCreateInput!): Workspace!
@hasScope(scope: "users:invite")
@hasServerRole(role: SERVER_USER)
batchCreate(workspaceId: String!, input: [WorkspaceInviteCreateInput!]!): Workspace!
@hasScope(scope: "users:invite")
@hasServerRole(role: SERVER_USER)
use(input: WorkspaceInviteUseInput!): Boolean!
cancel(workspaceId: String!, inviteId: String!): Workspace!
@hasScope(scope: "users:invite")
@hasServerRole(role: SERVER_USER)
}

type Workspace {
id: ID!
name: String!
description: String
createdAt: DateTime!
updatedAt: DateTime!
"""
Active user's role for this workspace. `null` if request is not authenticated, or the workspace is not explicitly shared with you.
"""
role: String
team: [WorkspaceCollaborator!]!
invitedTeam: [PendingWorkspaceCollaborator!]
projects(
limit: Int! = 25
cursor: String
filter: UserProjectsFilter
): ProjectCollection!
}

type WorkspaceCollaborator {
id: ID!
role: String!
user: LimitedUser!
}

type PendingWorkspaceCollaborator {
id: ID!
inviteId: String!
workspaceId: String!
workspaceName: String!
"""
E-mail address or name of the invited user
"""
title: String!
role: String!
invitedBy: LimitedUser!
"""
Set only if user is registered
"""
user: LimitedUser
"""
Only available if the active user is the pending workspace collaborator
"""
token: String
}

type WorkspaceCollection {
totalCount: Int!
cursor: String
items: [Workspace!]!
}

extend type User {
"""
Get the workspaces for the user
"""
workspaces(
limit: Int! = 25
cursor: String = null
filter: UserWorkspacesFilter
): WorkspaceCollection! @isOwner
}

extend type Project {
workspace: Workspace
}

type ServerWorkspacesInfo {
"""
This is a backend control variable for the workspaces feature set.
Since workspaces need a backend logic to be enabled, this is not enough as a feature flag.
"""
workspacesEnabled: Boolean!
}

extend type ServerInfo {
workspaces: ServerWorkspacesInfo!
}

extend type AdminQueries {
workspaceList(
query: String
limit: Int! = 25
cursor: String = null
): WorkspaceCollection!
}

input UserWorkspacesFilter {
search: String
}

enum WorkspaceRole {
ADMIN
MEMBER
GUEST
}
Loading

0 comments on commit 27179ad

Please sign in to comment.