I’m getting unexpected results where one query shows that I deleted an edge, but another query shows that I didn’t.
Here’s what I did:
- Created a Post with two [Tags]
- Remove one of the tags on the Post
- Get the individual Post, proving that the tag has been removed
- Get the individual Tag that was removed, proving that it no longer has a relationship with the Post
- Get Posts filtering by the deleted tag, and see that the Post the Tag was removed from is still showing up in search results for the Tag that it used to have. (!?)
How do I make it so that the Post no longer shows up when filtering Posts by the Tag that was removed from it?
The schema is like this:
type Post {
id: ID!
title: String!
Tags: [Tag] @hasInverse(field: Posts)
}
type Tag {
text: String! @id @search
Posts: [Discussion] @hasInverse(field: Tags)
}
First the Post was updated to have Tags:
mutation {
updatePost(
input: {
filter: {
id: ["0xfffd8d6aa9da05e8"]
},
set: {
title: "Updated title",
Tags: [{
text: "random-tag"
},{
text: "new-tag"
}]
},
}) {
post {
id
title
Tags {
text
}
}
}
}
Then new-tag
was removed:
mutation {
updatePost(
input: {
filter: {
id: ["0xfffd8d6aa9da05e8"]
},
remove: {
Tags: [{
text: "new-tag"
}]
}
}) {
post {
title
Tags {
text
}
}
}
}
When getting the Post by ID, it’s confirmed that new-tag
is no longer there:
query {
getDiscussion(id: "0xfffd8d6aa9da05e8") {
title
Author {
username
}
Tags {
text
}
}
}
Response:
"data": {
"getPost": {
"title": "Updated title",
"Tags": [
{
"text": "random-tag"
}
]
}
And when getting the tag new-tag
, it’s confirmed that it’s no longer connected to the Post:
query {
getTag (text: "new-tag"){
text
Posts {
id
title
Tags {
text
}
}
}
}
Response:
"data": {
"getTag": {
"text": "new-tag",
"Posts": []
}
}
That seems like the edge has been removed, but it hasn’t really. Because when I filter Posts based on Tags, the Post the tag was removed from still shows up in search results for that tag:
query {
queryPost @cascade(fields: ["Tags"]){
id
title
Tags (
filter: {
text: {
anyofterms: "new-tag"
}
}
){
text
}
}
}
Response:
"queryDiscussion": [
{
"id": "0xfffd8d6aa9da05e8",
"title": "Updated title",
"Tags": [
{
"text": "random-tag"
}
]
}
]
How can I get the Post to stop showing in results for the tag it used to have?