graphprotocol / graphprotocol/graph-node
Filtering for `null` nested entities
@kamilkisiela ya está trabajando en esto.
Desde el 26/10/2022.
- Lenguaje dominante
- Rust
- Estrellas
- 3.2k
- Forks
- 1.1k
- Merge medio
- 4 d 1 h
- PR fusionados (30 d)
- 1
Descripción
Given the following schema:
type BadgeSpec @entity {
id: String!
metadata: SpecMetadata
}
type SpecMetadata @entity {
id: ID!
name: String!
}
The BadgeSpec metadata field is populated with the ID of a SpecMetadata entity. At query time, that is used as a lookup to return a SpecMetadata entity, if there is one with a matching ID. If there is no matching ID, the metadata object returns as null.
Users might want to filter for BadgeSpecs with no connected metadata, and might expect the following query to do that:
{
badgeSpecs(where: {metadata: null}) {
id
metadata {
id
name
}
}
}
However that is not necessarily the current behaviour - filtering badgeSpecs on metadata filters on the value of the metadata field. So if the field is populated with an ID, but there isn't a SpecMetadata entity with that ID, then that BadgeSpec will not be returned. BadgeSpecs will only be returned when the value of the metadata field is itself null. There is currently no way to filter for all badgeSpecs with no connected metadata, regardless of whether the metadata field is populated.
Potential solutions:
- Update functionality for nested entities such that the filter reflects the nested entity's ID, so that
nullapplies where entities are not found. This is a change in behaviour, so raises the question: are there valid cases where users wouldn't expect filtering to work in this way? - Update nested filter functionality to filter for "null" IDs, i.e.
badgeSpecs(where: {metadata_: {id: null}}) {
id
metadata { id }
}
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.