Skip to content

Commit

Permalink
Fix codegen log for unhandled array types
Browse files Browse the repository at this point in the history
  • Loading branch information
dafaqdhruv committed Apr 4, 2023
1 parent aa3c984 commit e3c04f2
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions packages/codegen/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,39 @@ export class Visitor {
});

const typeName = node.returnParameters[0].typeName;
switch (typeName.type) {
case 'UserDefinedTypeName': {
const errorMessage = `No support in codegen for object of user defined type from method "${node.name}"`;
if (this._continueOnError) {
console.log(errorMessage);
return;
}
throw new Error(errorMessage);
}

case 'ArrayTypeName': {
const errorMessage = `No support in codegen for object of type "${typeName.baseTypeName.name}[]" from method "${node.name}"`;

// TODO Handle user defined type return.
if (typeName.type === 'UserDefinedTypeName') {
// Skip in case of UserDefinedTypeName.
return;
if (this._continueOnError) {
console.log(errorMessage);
return;
}

throw new Error(errorMessage);
}
}

// TODO Handle multiple return parameters and array return type.
const returnType = typeName.name;
try {
this._schema.addQuery(name, params, returnType);
this._resolvers.addQuery(name, params, returnType);
this._entity.addQuery(name, params, returnType);
this._database.addQuery(name, params, returnType);
this._client.addQuery(name, params, returnType);

assert(this._contract);
this._indexer.addQuery(this._contract.name, MODE_ETH_CALL, name, params, returnType);
} catch (error: any) {
if (!this._continueOnError) {
throw error;
}
console.log(error.message);
}

this._schema.addQuery(name, params, returnType);
this._resolvers.addQuery(name, params, returnType);
this._entity.addQuery(name, params, returnType);
this._database.addQuery(name, params, returnType);
this._client.addQuery(name, params, returnType);

assert(this._contract);
this._indexer.addQuery(this._contract.name, MODE_ETH_CALL, name, params, returnType);
}
}

Expand Down

0 comments on commit e3c04f2

Please sign in to comment.