Skip to content

Commit

Permalink
fix: document operations type
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Apr 3, 2024
1 parent cbc4666 commit da9729b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 47 deletions.
82 changes: 51 additions & 31 deletions api/src/graphql/generated/drive/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface NexusGenObjects {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['AccountSnapshotState']; // AccountSnapshotState!
}
Expand Down Expand Up @@ -195,7 +195,7 @@ export interface NexusGenObjects {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['BudgetStatementState']; // BudgetStatementState!
}
Expand Down Expand Up @@ -257,9 +257,15 @@ export interface NexusGenObjects {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
}
DefaultOperation: { // root type
hash: string; // String!
index: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
DocumentDriveState: { // root type
icon?: string | null; // String
id: string; // ID!
Expand Down Expand Up @@ -393,7 +399,7 @@ export interface NexusGenObjects {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['RealWorldAssetsState']; // RealWorldAssetsState!
}
Expand Down Expand Up @@ -432,7 +438,7 @@ export interface NexusGenObjects {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['ScopeFrameworkState']; // ScopeFrameworkState!
}
Expand Down Expand Up @@ -562,8 +568,8 @@ export interface NexusGenObjects {

export interface NexusGenInterfaces {
IDocument: NexusGenRootTypes['AccountSnapshot'] | NexusGenRootTypes['BudgetStatement'] | NexusGenRootTypes['DefaultDocument'] | NexusGenRootTypes['RealWorldAssets'] | NexusGenRootTypes['ScopeFramework'];
IOperation: NexusGenRootTypes['DefaultOperation'];
IRealWorldAssetsState: NexusGenRootTypes['RealWorldAssetsPortfolio'] | NexusGenRootTypes['RealWorldAssetsState'];
Operation: any;
System: NexusGenRootTypes['SwitchboardDrive'] | NexusGenRootTypes['SwitchboardHost'];
}

Expand All @@ -588,7 +594,7 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['AccountSnapshotState']; // AccountSnapshotState!
}
Expand Down Expand Up @@ -652,7 +658,7 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['BudgetStatementState']; // BudgetStatementState!
}
Expand Down Expand Up @@ -714,9 +720,15 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
}
DefaultOperation: { // field return type
hash: string; // String!
index: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
DocumentDriveState: { // field return type
icon: string | null; // String
id: string; // ID!
Expand Down Expand Up @@ -867,7 +879,7 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['RealWorldAssetsState']; // RealWorldAssetsState!
}
Expand Down Expand Up @@ -906,7 +918,7 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
state: NexusGenRootTypes['ScopeFrameworkState']; // ScopeFrameworkState!
}
Expand Down Expand Up @@ -1045,9 +1057,15 @@ export interface NexusGenFieldTypes {
id: string; // String!
lastModified: NexusGenScalars['Date']; // Date!
name: string; // String!
operations: NexusGenRootTypes['Operation'][]; // [Operation!]!
operations: NexusGenRootTypes['DefaultOperation'][]; // [DefaultOperation!]!
revision: number; // Int!
}
IOperation: { // field return type
hash: string; // String!
index: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
IRealWorldAssetsState: { // field return type
accounts: NexusGenRootTypes['Account'][]; // [Account!]!
fixedIncomeTypes: NexusGenRootTypes['FixedIncomeType'][]; // [FixedIncomeType!]!
Expand All @@ -1057,12 +1075,6 @@ export interface NexusGenFieldTypes {
spvs: NexusGenRootTypes['Spv'][]; // [Spv!]!
transactions: NexusGenRootTypes['GroupTransaction'][]; // [GroupTransaction!]!
}
Operation: { // field return type
hash: string; // String!
index: number; // Int!
timestamp: NexusGenScalars['Date']; // Date!
type: string; // String!
}
System: { // field return type
auth: NexusGenRootTypes['Auth'] | null; // Auth
}
Expand All @@ -1080,7 +1092,7 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
state: 'AccountSnapshotState'
}
Expand Down Expand Up @@ -1144,7 +1156,7 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
state: 'BudgetStatementState'
}
Expand Down Expand Up @@ -1206,9 +1218,15 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
}
DefaultOperation: { // field return type name
hash: 'String'
index: 'Int'
timestamp: 'Date'
type: 'String'
}
DocumentDriveState: { // field return type name
icon: 'String'
id: 'ID'
Expand Down Expand Up @@ -1359,7 +1377,7 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
state: 'RealWorldAssetsState'
}
Expand Down Expand Up @@ -1398,7 +1416,7 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
state: 'ScopeFrameworkState'
}
Expand Down Expand Up @@ -1537,9 +1555,15 @@ export interface NexusGenFieldTypeNames {
id: 'String'
lastModified: 'Date'
name: 'String'
operations: 'Operation'
operations: 'DefaultOperation'
revision: 'Int'
}
IOperation: { // field return type name
hash: 'String'
index: 'Int'
timestamp: 'Date'
type: 'String'
}
IRealWorldAssetsState: { // field return type name
accounts: 'Account'
fixedIncomeTypes: 'FixedIncomeType'
Expand All @@ -1549,12 +1573,6 @@ export interface NexusGenFieldTypeNames {
spvs: 'Spv'
transactions: 'GroupTransaction'
}
Operation: { // field return type name
hash: 'String'
index: 'Int'
timestamp: 'Date'
type: 'String'
}
System: { // field return type name
auth: 'Auth'
}
Expand Down Expand Up @@ -1609,6 +1627,7 @@ export interface NexusGenAbstractTypeMembers {
Asset: "Cash" | "FixedIncome"
ElementComponents: "ArticleComponent" | "CoreComponent" | "ScopeComponent" | "SectionComponent" | "TypeSpecificationComponent"
IDocument: "AccountSnapshot" | "BudgetStatement" | "DefaultDocument" | "RealWorldAssets" | "ScopeFramework"
IOperation: "DefaultOperation"
IRealWorldAssetsState: "RealWorldAssetsPortfolio" | "RealWorldAssetsState"
System: "SwitchboardDrive" | "SwitchboardHost"
}
Expand All @@ -1617,6 +1636,7 @@ export interface NexusGenTypeInterfaces {
AccountSnapshot: "IDocument"
BudgetStatement: "IDocument"
DefaultDocument: "IDocument"
DefaultOperation: "IOperation"
RealWorldAssets: "IDocument"
RealWorldAssetsPortfolio: "IRealWorldAssetsState"
RealWorldAssetsState: "IRealWorldAssetsState"
Expand All @@ -1639,7 +1659,7 @@ export type NexusGenUnionNames = keyof NexusGenUnions;

export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never;

export type NexusGenAbstractsUsingStrategyResolveType = "Asset" | "ElementComponents" | "IDocument" | "IRealWorldAssetsState" | "Operation" | "System";
export type NexusGenAbstractsUsingStrategyResolveType = "Asset" | "ElementComponents" | "IDocument" | "IOperation" | "IRealWorldAssetsState" | "System";

export type NexusGenFeaturesConfig = {
abstractTypeStrategies: {
Expand Down
33 changes: 20 additions & 13 deletions api/src/graphql/generated/drive/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AccountSnapshot implements IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
state: AccountSnapshotState!
}
Expand Down Expand Up @@ -100,7 +100,7 @@ type BudgetStatement implements IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
state: BudgetStatementState!
}
Expand Down Expand Up @@ -181,10 +181,17 @@ type DefaultDocument implements IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
}

type DefaultOperation implements IOperation {
hash: String!
index: Int!
timestamp: Date!
type: String!
}

type DocumentDriveState {
icon: String
id: ID!
Expand Down Expand Up @@ -257,10 +264,17 @@ interface IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
}

interface IOperation {
hash: String!
index: Int!
timestamp: Date!
type: String!
}

interface IRealWorldAssetsState {
accounts: [Account!]!
fixedIncomeTypes: [FixedIncomeType!]!
Expand Down Expand Up @@ -389,13 +403,6 @@ type Node {
parentFolder: String
}

interface Operation {
hash: String!
index: Int!
timestamp: Date!
type: String!
}

type OperationUpdate {
hash: String!
index: Int!
Expand Down Expand Up @@ -427,7 +434,7 @@ type RealWorldAssets implements IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
state: RealWorldAssetsState!
}
Expand Down Expand Up @@ -472,7 +479,7 @@ type ScopeFramework implements IDocument {
id: String!
lastModified: Date!
name: String!
operations: [Operation!]!
operations: [DefaultOperation!]!
revision: Int!
state: ScopeFrameworkState!
}
Expand Down
15 changes: 12 additions & 3 deletions api/src/modules/document/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ const logger = getChildLogger({ msgPrefix: 'DOCUMENT RESOLVER' });

// todo: resolveType should be moved to somewhere else
export const operationModelInterface = interfaceType({
name: 'Operation',
name: 'IOperation',
definition(t) {
t.nonNull.string('type');
t.nonNull.int('index');
t.nonNull.field('timestamp', { type: GQLDateBase });
t.nonNull.string('hash');
},
resolveType: (e) => 'Operation',
resolveType: (e) => {
return "DefaultOperation"
},
});

export const operationModel = objectType({
name: 'DefaultOperation',
definition(t) {
t.implements(operationModelInterface)
},
});

// todo: resolveType should be moved to somewhere else
Expand All @@ -27,7 +36,7 @@ export const documentModelInterface = interfaceType({
t.nonNull.int('revision');
t.nonNull.field('created', { type: GQLDateBase });
t.nonNull.field('lastModified', { type: GQLDateBase });
t.nonNull.list.nonNull.field('operations', { type: operationModelInterface });
t.nonNull.list.nonNull.field('operations', { type: operationModel });
},
resolveType: (e) => {
switch (e.documentType) {
Expand Down

0 comments on commit da9729b

Please sign in to comment.