Implement block filter for plural queries on subgraph entities (#444)

* Fix bigint values transformation

* Fix starts and ends filter operator resolution

* Support case insensitive filters for string fields

* Add support for global filter _change_block

* Handle _change_block filter in all query types
This commit is contained in:
prathamesh0
2023-11-01 10:42:56 +05:30
committed by GitHub
parent 6c17662cad
commit 1b6ca6edeb
3 changed files with 61 additions and 6 deletions
+18 -1
View File
@@ -27,7 +27,8 @@ import {
getSubgraphConfig,
Transaction,
EthClient,
DEFAULT_LIMIT
DEFAULT_LIMIT,
FILTER_CHANGE_BLOCK
} from '@cerc-io/util';
import { Context, GraphData, instantiate } from './loader';
@@ -322,6 +323,17 @@ export class GraphWatcher {
try {
where = Object.entries(where).reduce((acc: { [key: string]: any }, [fieldWithSuffix, value]) => {
if (fieldWithSuffix === FILTER_CHANGE_BLOCK) {
assert(value.number_gte && typeof value.number_gte === 'number');
// Maintain util.Where type
acc[FILTER_CHANGE_BLOCK] = [{
value: value.number_gte
}];
return acc;
}
const [field, ...suffix] = fieldWithSuffix.split('_');
if (!acc[field]) {
@@ -345,6 +357,11 @@ export class GraphWatcher {
filter.operator = operator;
}
// If filter field ends with "nocase", use case insensitive version of the operator
if (suffix[suffix.length - 1] === 'nocase') {
filter.operator = `${operator}_nocase`;
}
acc[field].push(filter);
return acc;