0xPlaygrounds / 0xPlaygrounds/kg-node
feat(api): Add `exists` flag to attribute filter
- 主要言語
- Rust
- スター
- 10
- フォーク
- 5
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
### Description
Add an `exists` field to the `EntityAttributeFilter` input object
**Schema**
```graphql
input EntityAttributeFilter {
attribute: String!
exists: Boolean! = true # <---------- NEW
value: String
valueNot: String
valueIn: [String!]
valueNotIn: [String!]
valueType: ValueType
valueTypeNot: ValueType
valueTypeIn: [ValueType!]
valueTypeNotIn: [ValueType!]
}
```
**Example Query**
```graphql
query {
entities(
# Select entities for which the name attribute ("LuBWqZAu6pz54eiJS5mLv8") exists
where: {
attributes: [
{attribute: "LuBWqZAu6pz54eiJS5mLv8", exists: true}
]
},
spaceId: "25omwWh6HYgeRQKCaSpVpa",
first: 10
) {
id
...
}
}
```
### Implementation checklist
- [ ] Update the `PropFilter` struct in the `grc20-core/src/mapping/query_utils/prop_filter.rs` module
- [ ] Add the `exists: Option` field to the struct
- [ ] Update the `PropFilter::subquery` method to apply the an `{field} IS NOT null` or `{field} IS null` filter (if it is not `None`) to the where clause **only if** no other filter have been applied.
- [ ] Update the `EntityAttributeFilter` struct in the `api/src/schema/attribute_filter.rs` module
- [ ] Add the `exists` field to the struct
- [ ] Update the `impl From for mapping::AttributeFilter` block
- [ ] Update the `EntityAttributeFilter::value_filter` method to set the new `exists` field on the `PropFilter`
- [ ] Test!
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
The work is in two files: grc20-core/src/mapping/query_utils/prop_filter.rs and api/src/schema/attribute_filter.rs. Start by reading the PropFilter struct and its subquery method to understand how filters are applied. Then update the EntityAttributeFilter struct and its conversion to mapping::AttributeFilter. The task is to add an exists flag that adds an IS NOT null or IS null condition to the SQL where clause only when no other filters are applied. Testing will involve verifying the GraphQL query works as shown.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- graphql, rust
- 領域
- api, backend, databases
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100