Hi all,
I am able to return results for one or two tags that have been added to posts, but all other tags seemingly return an empty set despite being added/published in the exact same way. Has anyone run into difficulties with gatsby/graphql/prismic when querying by tags?
Thanks!
Hi there,
Thanks for contributing to Prismic community, if I understood well querying by tag returns empty result for some tags or you mean when querying multiple tags you get some empty?
Looking forward to your reply,
Fares
Querying by one tag will return empty (except for one or two of the tags), so is inconsistent and works in some cases with no clear difference. Querying by multiple tags also will always return empty.
Thanks!
In fact I’ve tried to reproduce the issue but for me it seems to work correctly
Here is the query I have used:
{
allPosts(tags:"test-page") {
edges {
node {
title
}
}
}
}
The query result:
{
"data": {
"allPosts": {
"edges": [
{
"node": {
"title": [
{
"type": "heading1",
"text": "Test-2",
"spans": []
}
]
}
},
{
"node": {
"title": [
{
"type": "heading1",
"text": "Test-35",
"spans": []
}
]
}
},
{
"node": {
"title": [
{
"type": "heading1",
"text": "Test-1",
"spans": []
}
]
}
}
]
}
}
}
Please note: one issue I had when testing was that I was trying filter some other document type tags that’s why they didn’t appear.
Can you please share with us the query you doing, the query result as well as your repository (you can send me a direct message if you don’t want that to be public).
I didn’t want this reply to be public so deleted the post on the forum that was automatically added by the last email, not seeing a way to DM you otherwise?
Hey Zach,
Our new users weren’t at the correct trust level to send private message. MY BAD
You should be able to send a message now.
Thanks.
I’ve been able to reproduce the issue and it turns out that you have some trailing spaces in some tags that is why filter by some tags is not working
Here is some examples:
"nutrition "
"healthy eating "
Here is an example of a working query:
{
_allDocuments(tags:["healthy eating "]) {
totalCount
}
}
And in order to be able to fix this you need to remove the usage of those tags and recreate them without the trailing spaces.
Can you confirm if that solves the issue?
Confirmed! Issue was user added trailing spaces to some of the tags.
Thank you so much!!