Skip to content

Commit

Permalink
feat: set drive icon mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Jul 8, 2024
1 parent 5ea233d commit 40e7476
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"cors": "^2.8.5",
"document-drive": "1.0.0-alpha.80",
"document-model": "1.7.0",
"document-model-libs": "^1.69.0",
"document-model-libs": "^1.70.0",
"dotenv": "^16.4.5",
"esbuild": "^0.21.2",
"ethers": "^5.7.2",
Expand Down
14 changes: 7 additions & 7 deletions api/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions api/src/graphql/server/generated/index/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export interface NexusGenInputs {
expiryDurationSeconds?: number | null; // Int
name: string; // String!
}
SetDriveIconInput: { // input type
icon: string; // String!
}
}

export interface NexusGenEnums {
Expand Down Expand Up @@ -193,6 +196,7 @@ export interface NexusGenFieldTypes {
createSession: NexusGenRootTypes['SessionOutput'] | null; // SessionOutput
deleteDrive: boolean | null; // Boolean
revokeSession: NexusGenRootTypes['Session'] | null; // Session
setDriveIcon: boolean | null; // Boolean
solveChallenge: NexusGenRootTypes['SessionOutput'] | null; // SessionOutput
}
Node: { // field return type
Expand Down Expand Up @@ -277,6 +281,7 @@ export interface NexusGenFieldTypeNames {
createSession: 'SessionOutput'
deleteDrive: 'Boolean'
revokeSession: 'Session'
setDriveIcon: 'Boolean'
solveChallenge: 'SessionOutput'
}
Node: { // field return type name
Expand Down Expand Up @@ -338,6 +343,10 @@ export interface NexusGenArgTypes {
revokeSession: { // args
sessionId: string; // String!
}
setDriveIcon: { // args
icon: string; // String!
id: string; // String!
}
solveChallenge: { // args
nonce: string; // String!
signature: string; // String!
Expand Down
5 changes: 5 additions & 0 deletions api/src/graphql/server/generated/index/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Mutation {
createSession(session: SessionInput!): SessionOutput
deleteDrive(id: String!): Boolean
revokeSession(sessionId: String!): Session
setDriveIcon(icon: String!, id: String!): Boolean
solveChallenge(nonce: String!, signature: String!): SessionOutput
}

Expand Down Expand Up @@ -108,6 +109,10 @@ type SessionOutput {
token: String!
}

input SetDriveIconInput {
icon: String!
}

type SwitchboardHost implements System {
auth: Auth
}
Expand Down
24 changes: 24 additions & 0 deletions api/src/modules/document-drive/drives-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export const DocumentDriveStateInput = inputObjectType({
},
});

export const SetDriveIconInput = inputObjectType({
name: "SetDriveIconInput",
definition(t) {
t.nonNull.string("icon")
}
});

export const getDrives = queryField('drives', {
type: list('String'),
resolve: async (_parent, args, ctx: Context) => {
Expand Down Expand Up @@ -113,3 +120,20 @@ export const deleteDrive = mutationField('deleteDrive', {
return true;
},
});

export const setDriveIcon = mutationField('setDriveIcon', {
type: 'Boolean',
args: {
id: nonNull('String'),
icon: nonNull('String'),
},
resolve: async (_parent, { id, icon }, ctx: Context) => {
try {
await ctx.prisma.document.setDriveIcon(id, icon);
} catch (e: any) {
throw new DocumentDriveError({ code: 500, message: e.message ?? "Failed to set drive icon", logging: true, context: e })
}

return true;
}
});
3 changes: 3 additions & 0 deletions api/src/modules/document/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export function getDocumentDriveCRUD(prisma: Prisma.TransactionClient) {
return documents;
},

setDriveIcon: async (driveId: string, icon: string) => {
return await driveServer.queueDriveAction(driveId, actions.setDriveIcon({ icon }));
},
closeScopeOfWorkIssue: async (githubId: number) => {
// const dbEntry = await prisma.scopeOfWorkDeliverable.findFirst({
// where: {
Expand Down

0 comments on commit 40e7476

Please sign in to comment.