Skip to content

Commit

Permalink
feat: added more drive info to drive query
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Sep 12, 2024
1 parent 69d30b0 commit 328a9fa
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions api/src/graphql/server/generated/drive/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,12 @@ export interface NexusGenObjects {
type: string; // String!
}
DocumentDriveState: { // root type
availableOffline: boolean; // Boolean!
icon?: string | null; // String
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
sharingType?: string | null; // String
slug?: string | null; // String
}
FixedIncome: { // root type
Expand Down Expand Up @@ -771,10 +773,12 @@ export interface NexusGenFieldTypes {
type: string; // String!
}
DocumentDriveState: { // field return type
availableOffline: boolean; // Boolean!
icon: string | null; // String
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
sharingType: string | null; // String
slug: string | null; // String
}
FixedIncome: { // field return type
Expand Down Expand Up @@ -1280,10 +1284,12 @@ export interface NexusGenFieldTypeNames {
type: 'String'
}
DocumentDriveState: { // field return type name
availableOffline: 'Boolean'
icon: 'String'
id: 'ID'
name: 'String'
nodes: 'Node'
sharingType: 'String'
slug: 'String'
}
FixedIncome: { // field return type name
Expand Down
2 changes: 2 additions & 0 deletions api/src/graphql/server/generated/drive/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ type DefaultOperation implements IOperation {
}

type DocumentDriveState {
availableOffline: Boolean!
icon: String
id: ID!
name: String!
nodes: [Node]!
sharingType: String
slug: String
}

Expand Down
6 changes: 6 additions & 0 deletions api/src/graphql/server/generated/index/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ export interface NexusGenObjects {
sharingType?: string | null; // String
}
DocumentDriveState: { // root type
availableOffline: boolean; // Boolean!
icon?: string | null; // String
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
sharingType?: string | null; // String
slug?: string | null; // String
}
Mutation: {};
Expand Down Expand Up @@ -184,10 +186,12 @@ export interface NexusGenFieldTypes {
sharingType: string | null; // String
}
DocumentDriveState: { // field return type
availableOffline: boolean; // Boolean!
icon: string | null; // String
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
sharingType: string | null; // String
slug: string | null; // String
}
Mutation: { // field return type
Expand Down Expand Up @@ -270,10 +274,12 @@ export interface NexusGenFieldTypeNames {
sharingType: 'String'
}
DocumentDriveState: { // field return type name
availableOffline: 'Boolean'
icon: 'String'
id: 'ID'
name: 'String'
nodes: 'Node'
sharingType: 'String'
slug: 'String'
}
Mutation: { // field return type name
Expand Down
2 changes: 2 additions & 0 deletions api/src/graphql/server/generated/index/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ input DocumentDriveLocalStateInput {
}

type DocumentDriveState {
availableOffline: Boolean!
icon: String
id: ID!
name: String!
nodes: [Node]!
sharingType: String
slug: String
}

Expand Down
9 changes: 6 additions & 3 deletions api/src/modules/document-drive/drive-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Node = objectType({
}
});


export const DocumentDriveStateObject = objectType({
name: 'DocumentDriveState',
definition(t) {
Expand All @@ -45,6 +46,8 @@ export const DocumentDriveStateObject = objectType({
t.nonNull.list.field('nodes', { type: Node });
t.string('icon');
t.string('slug');
t.string("sharingType");
t.nonNull.boolean("availableOffline");
}
});

Expand Down Expand Up @@ -318,10 +321,10 @@ export const getDrive = queryField('drive', {
type: DocumentDriveStateObject,
resolve: async (_parent, _args, ctx: Context) => {
try {
const drive = (await ctx.prisma.document.getDrive(
const {global, local} = (await ctx.prisma.document.getDrive(
ctx.driveId ?? '1'
)) as DocumentDriveState;
return drive;
)) ;
return {...global, ...local, sharingType: local.sharingType?.toUpperCase() ?? null};
} catch (e: any) {
throw new DocumentDriveError({
code: 500,
Expand Down
2 changes: 1 addition & 1 deletion api/src/modules/document/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function getDocumentDriveCRUD(prisma: Prisma.TransactionClient) {
getDrive: async (id: string) => {
try {
const { state } = await driveServer.getDrive(id);
return state.global;
return state;
} catch (e) {
logger.error(e);
throw new Error('Drive not found');
Expand Down

0 comments on commit 328a9fa

Please sign in to comment.