-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspaces): stencil gql resolvers (#2508)
* 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
Showing
10 changed files
with
1,067 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
176 changes: 176 additions & 0 deletions
176
packages/server/assets/workspacesCore/typedefs/workspaces.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.