Skip to content

Commit

Permalink
feat: added operations and initialState to getDocument query
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Sep 12, 2024
1 parent ff0564e commit 191272e
Show file tree
Hide file tree
Showing 10 changed files with 1,112 additions and 1,487 deletions.
2,428 changes: 1,022 additions & 1,406 deletions api/src/graphql/server/generated/drive/nexus.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/src/graphql/server/generated/drive/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type BudgetStatement implements IDocument {
created: Date!
documentType: String!
id: String!
initialState: BudgetStatementState!
lastModified: Date!
name: String!
operations: [DefaultOperation!]!
Expand Down Expand Up @@ -207,6 +208,7 @@ type DocumentDrive implements IDocument {
created: Date!
documentType: String!
id: String!
initialState: DocumentDriveState!
lastModified: Date!
name: String!
operations: [DefaultOperation!]!
Expand Down Expand Up @@ -560,6 +562,7 @@ type ScopeFramework implements IDocument {
created: Date!
documentType: String!
id: String!
initialState: ScopeFrameworkState!
lastModified: Date!
name: String!
operations: [DefaultOperation!]!
Expand Down
13 changes: 13 additions & 0 deletions api/src/graphql/server/generated/index/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ export interface NexusGenObjects {
hash: string; // String!
id?: string | null; // String
index: number; // Int!
inputText: string; // String!
skip: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
DocumentDrive: { // root type
created: NexusGenScalars['Date']; // Date!
documentType: string; // String!
id: string; // String!
initialState: NexusGenRootTypes['DocumentDriveState']; // DocumentDriveState!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
Expand Down Expand Up @@ -250,13 +253,16 @@ export interface NexusGenFieldTypes {
hash: string; // String!
id: string | null; // String
index: number; // Int!
inputText: string; // String!
skip: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
DocumentDrive: { // field return type
created: NexusGenScalars['Date']; // Date!
documentType: string; // String!
id: string; // String!
initialState: NexusGenRootTypes['DocumentDriveState']; // DocumentDriveState!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
Expand Down Expand Up @@ -376,6 +382,8 @@ export interface NexusGenFieldTypes {
hash: string; // String!
id: string | null; // String
index: number; // Int!
inputText: string; // String!
skip: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
Expand Down Expand Up @@ -418,13 +426,16 @@ export interface NexusGenFieldTypeNames {
hash: 'String'
id: 'String'
index: 'Int'
inputText: 'String'
skip: 'Int'
timestamp: 'Date'
type: 'String'
}
DocumentDrive: { // field return type name
created: 'Date'
documentType: 'String'
id: 'String'
initialState: 'DocumentDriveState'
lastModified: 'Date'
name: 'String'
operations: 'DefaultOperation'
Expand Down Expand Up @@ -544,6 +555,8 @@ export interface NexusGenFieldTypeNames {
hash: 'String'
id: 'String'
index: 'Int'
inputText: 'String'
skip: 'Int'
timestamp: 'Date'
type: '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 @@ -39,6 +39,8 @@ type DefaultOperation implements IOperation {
hash: String!
id: String
index: Int!
inputText: String!
skip: Int!
timestamp: Date!
type: String!
}
Expand All @@ -47,6 +49,7 @@ type DocumentDrive implements IDocument {
created: Date!
documentType: String!
id: String!
initialState: DocumentDriveState!
lastModified: Date!
name: String!
operations: [DefaultOperation!]!
Expand Down Expand Up @@ -111,6 +114,8 @@ interface IOperation {
hash: String!
id: String
index: Int!
inputText: String!
skip: Int!
timestamp: Date!
type: String!
}
Expand Down
1 change: 1 addition & 0 deletions api/src/modules/budget-statement/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,6 @@ export const BudgetStatementDocument = objectType({
definition(t) {
t.implements(documentModelInterface);
t.nonNull.field('state', { type: BudgetStatementState });
t.nonNull.field('initialState', { type: BudgetStatementState });
}
});
1 change: 1 addition & 0 deletions api/src/modules/document-drive/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,6 @@ export const DocumentDriveDocument = objectType({
definition(t) {
t.implements(documentModelInterface);
t.nonNull.field('state', { type: DocumentDriveState });
t.nonNull.field('initialState', { type: DocumentDriveState });
}
});
7 changes: 6 additions & 1 deletion api/src/modules/document/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ export function getDocumentDriveCRUD(prisma: Prisma.TransactionClient) {
id: documentId,
revision: document.revision.global,
state: document.state.global,
operations: document.operations.global
operations: document.operations.global.map(op => ({
...op,
inputText:
typeof op.input === 'string' ? op.input : JSON.stringify(op.input)
})),
initialState: document.initialState.state.global
};
return response;
},
Expand Down
7 changes: 4 additions & 3 deletions api/src/modules/document/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const operationModelInterface = interfaceType({
definition(t) {
t.nonNull.string('type');
t.nonNull.int('index');
t.nonNull.int('skip');
t.nonNull.field('timestamp', { type: GQLDateBase });
t.nonNull.string('hash');
t.string('id');
t.nonNull.string('inputText');
},
resolveType: e => {
return 'DefaultOperation';
Expand Down Expand Up @@ -85,13 +87,12 @@ export const documentsQuery = queryField('documents', {
try {
const docIds = await ctx.prisma.document.getDocuments(ctx.driveId);
const docs = await Promise.all(
docIds.map(doc => {
return ctx.prisma.document.getDocument(ctx.driveId!, doc);
})
docIds.map(doc => ctx.prisma.document.getDocument(ctx.driveId!, doc))
);
return docs;
} catch (e: any) {
logger.error({ msg: e.message });
throw e;
}
}
});
Loading

0 comments on commit 191272e

Please sign in to comment.