diff --git a/packages/codegen/src/schema.ts b/packages/codegen/src/schema.ts index 41b19fa43..2237b233f 100644 --- a/packages/codegen/src/schema.ts +++ b/packages/codegen/src/schema.ts @@ -197,7 +197,6 @@ export class Schema { } }; - // TODO: Add query type filter (subgraphType_filter) (input) // Add plural query // Create the subgraphType_orderBy enum type @@ -219,8 +218,9 @@ export class Schema { // Get type composer object for return type from the schema composer. type: this._composer.getAnyTC(subgraphType).NonNull.List.NonNull, args: { - // where: Staker_filter, block: BlockHeight, + // TODO: Create input type for where clause + // where: subgraphType_filter, orderBy: subgraphTypeOrderByEnum, orderDirection: OrderDirection, first: { type: GraphQLInt, defaultValue: 100 }, diff --git a/packages/util/src/database.ts b/packages/util/src/database.ts index 25c31741a..bfc6ac8ab 100644 --- a/packages/util/src/database.ts +++ b/packages/util/src/database.ts @@ -829,12 +829,10 @@ export class Database { whereClause += `${OPERATOR_MAP[operator]} `; + value = this._transformBigIntValues(value); if (operator === 'in') { whereClause += '(:...'; } else { - // Convert to string type value as bigint type throws error in query. - value = value.toString(); - whereClause += ':'; } @@ -900,4 +898,20 @@ export class Database { eventCount.set(res); } + + _transformBigIntValues (value: any): any { + if (Array.isArray(value)) { + if (value.length > 0 && typeof value[0] === 'bigint') { + return value.map(val => { + return val.toString(); + }); + } + + return value; + } + + if (typeof value === 'bigint') { + return value.toString(); + } + } }