Open azf20 opened 2 years ago
Maybe metadata_is_null: true / false
? Sending null
is kind of limiting and might result in special treating of it in graph-node.
type Query {
feed: Article
}
type Article {
id: ID!
title: String!
description: String
body: String!
}
With description_is_null: true
we show all articles without descriptions, description_is_null: false
would result in the opposite, only articles with with descriptions.
@kamilkisiela yes I think that can make sense as a more explicit filter. Would you make it a specific filter to the nested entity case from the OP?
@kamilkisiela yes I think that can make sense as a more explicit filter. Would you make it a specific filter to the nested entity case from the OP?
I think we can have it for all kinds of fields? (not just nested)
because null
can be set on first-level fields that are defined as nullable?
As long as it works for the specific case mentioned (nested entities, where the value in the first-level table is not null, but there is no entity in the child table) - it is already possible to filter for null
first-level fields
Given the schema
type BadgeSpec @entity {
id: String!
metadata: SpecMetadata
}
type SpecMetadata @entity {
id: ID!
name: String!
}
The following query
{ badgeSpecs(where: {metadata_exists: false}) { ... } }
will be translated to:
SELECT ... FROM badge_spec WHERE metadata IS NULL
If it's derived, then the SQL will be:
SELECT ... FROM badge_spec WHERE NOT EXISTS (
SELECT 1 FROM spec_metadata WHERE badge_spec.metadata = spec_metadata.id
)
Does it make sense, that's what we try to achieve?
Another question. Should we support only 1-to-1 connection?
hey @kamilkisiela that sounds good to me! I think at the outset 1-to-1 is a reasonable starting point
Looks like this issue has been open for 6 months with no activity. Is it still relevant? If not, please remember to close it.
Given the following schema:
The BadgeSpec
metadata
field is populated with the ID of aSpecMetadata
entity. At query time, that is used as a lookup to return aSpecMetadata
entity, if there is one with a matching ID. If there is no matching ID, the metadata object returns asnull
.Users might want to filter for
BadgeSpecs
with no connectedmetadata
, and might expect the following query to do that:However that is not necessarily the current behaviour - filtering
badgeSpecs
onmetadata
filters on the value of themetadata
field. So if the field is populated with an ID, but there isn't aSpecMetadata
entity with that ID, then thatBadgeSpec
will not be returned.BadgeSpecs
will only be returned when the value of themetadata
field is itselfnull
. There is currently no way to filter for allbadgeSpecs
with no connectedmetadata
, regardless of whether themetadata
field is populated.Potential solutions:
null
applies 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?