Skip to content

feat(api): Add exists flag to attribute filter #49

@cvauclair

Description

@cvauclair

Description

Add an exists field to the EntityAttributeFilter input object

Schema

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

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<bool> 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<EntityAttributeFilter> for mapping::AttributeFilter block
    • Update the EntityAttributeFilter::value_filter method to set the new exists field on the PropFilter
  • Test!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions