I have a subscription
subscription MySubscription {
Trip(filter: {node: {owner: {id: {equals: "ck3w4evzb000408lef4lldkmg"}}}}){
mutation
node {
id
name
}
}
}
which works (using the 8Base API explorer) when I create a table, however when I delete the table with the data explorer, the deletion subscription does not fire. Is this a bug or is this not supported? I am trying to maintain a list of items and need to be able to observe deletions as well as insertions and updates (updates work as well).
Hey Mathie,
I’m assuming that since you’re filtering on records belonging to an owner, once you delete a Trip it no longer is belonging to that owner through that relationship. I’ll look into whether this is a bug or by design.
I just tried it in the API Explorer and replicated the issue in a Todos app workspace. Here is what I’d suggest.
This will work for both create and delete if the “owner” or the trip is always the user who created the trip, as 8base always stores who created the record on authenticated requests.
subscription MySubscription {
Todos(filter: {
mutation_in: [create, delete]
node: {
createdBy: {
id: {
equals: "cjz1n2tq100fe01jt4bi4ekrl"
}
}
}
}) {
mutation
node {
id
status
}
}
}
Or, simply use both for now so that you’re getting deletes updates on the createdBy and all others on the owner relationship, and then we’ll let you know when we know what’s happening.
subscription MySubscription {
Todos(filter: {
mutation_in: [create, delete]
node: {
OR: [
{
owner: {
id: {
equals: "cjz1n2tq100fe01jt4bi4ekrl"
}
}
},
{
createdBy: {
id: {
equals: "cjz1n2tq100fe01jt4bi4ekrl"
}
}
}
]
}
}){
mutation
node {
id
status
}
}
}
This can also be written nicer as:
subscription($userFilter: UserFilter!) {
Todos(filter: {
mutation_in: [create, delete]
node: {
OR: [
{ owner: $userFilter },
{ createdBy: $userFilter }
]
}
}){
mutation
node {
id
status
}
}
}