diff --git a/common/changes/@subsquid/openreader/master_2024-09-06-16-26.json b/common/changes/@subsquid/openreader/master_2024-09-06-16-26.json new file mode 100644 index 00000000..9bb4a117 --- /dev/null +++ b/common/changes/@subsquid/openreader/master_2024-09-06-16-26.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@subsquid/openreader", + "comment": "extend `thegraph` dialect fk filter with more conditions", + "type": "patch" + } + ], + "packageName": "@subsquid/openreader" +} \ No newline at end of file diff --git a/graphql/openreader/src/dialect/thegraph/schema.ts b/graphql/openreader/src/dialect/thegraph/schema.ts index 79034ed4..a6eeaeae 100644 --- a/graphql/openreader/src/dialect/thegraph/schema.ts +++ b/graphql/openreader/src/dialect/thegraph/schema.ts @@ -299,18 +299,44 @@ export class SchemaBuilder { fields[key] = {type: this.getWhere(prop.type.name)} break case 'fk': - case 'lookup': + // TODO: needs to be changed in case if we support non-string ids + let type = GraphQLString + let listType = new GraphQLList(new GraphQLNonNull(type)) + + fields[`${key}`] = {type} + fields[`${key}_not`] = {type} + fields[`${key}_gt`] = {type} + fields[`${key}_gte`] = {type} + fields[`${key}_lt`] = {type} + fields[`${key}_lte`] = {type} + fields[`${key}_in`] = {type: listType} + fields[`${key}_not_in`] = {type: listType} + fields[`${key}_contains`] = {type} + fields[`${key}_not_contains`] = {type} + fields[`${key}_contains_nocase`] = {type} + fields[`${key}_not_contains_nocase`] = {type} + fields[`${key}_starts_with`] = {type} + fields[`${key}_starts_with_nocase`] = {type} + fields[`${key}_not_starts_with`] = {type} + fields[`${key}_not_starts_with_nocase`] = {type} + fields[`${key}_ends_with`] = {type} + fields[`${key}_ends_with_nocase`] = {type} + fields[`${key}_not_ends_with`] = {type} + fields[`${key}_not_ends_with_nocase`] = {type} fields[`${key}_is_null`] = {type: GraphQLBoolean} fields[`${key}_`] = {type: this.getWhere(prop.type.entity)} - fields[`${key}_in`] = {type: new GraphQLList(new GraphQLNonNull(GraphQLString))} break - case 'list-lookup': { + case 'lookup': { + fields[`${key}_is_null`] = {type: GraphQLBoolean} + fields[`${key}_`] = {type: this.getWhere(prop.type.entity)} + break + } + case 'list-lookup': let where = this.getWhere(prop.type.entity) fields[`${key}_every`] = {type: where} fields[`${key}_some`] = {type: where} fields[`${key}_none`] = {type: where} break - } } }