Hi all
I would like to run a query against an object that has a list predicate and want to receive only results that contain (or not contain) a certain value. I looked at the in filter function, but that does not work on the predicate.
Example type:
type MyLabel {
name: String! @id @search(by: [exact, trigram])
objects: [ MyObject ] @hasInverse(field: matches)
}
type MyObject {
name: String! @id @search(by: [term])
labels: [ MyLabel ] @hasInverse(field: objects)
}
lets say I have two Labels with the names foo and bar and I want to filter all MyObjects that are not labelled with foo.
I tried a query like
query {
queryMyObject(filter: {name: {regexp: "/^trials/i"}}) @cascade {
labels(filter: {not: {name: { eq: "foo" } } }) {
label
}
}
}
This gives me all objects with a name that starts with trials and with labels other than foo. However, I want to get only the objects that don’t have label foo in their labels list at all and not just remove foo from the labels list. The in function works in the other direction and is therefore no option, either.
I would like to do something like the following.
query {
queryMyObject(filter: {name: {regexp: "/^trials/i"}}) @cascade {
labels(filter: {not: {name: { contains: "foo" } } }) {
label
}
}
}
This obviously does not work.
I feel a bit at a loss here and wonder what would be a smart solution to retrieve all MyObjects that don’t contain a certain label in a list predicate. While the positive case without not is trivial, the inverse appears to be impossible.
Thank you for your advise and better query strategies
Christian.