Hi all,
I am using Strapi (3.4.6) and GraphQL to query data in order to display the number of results displayed of the number of results fetched. My initial query looks like this:
query resources($keyword: String, $languages: [String], $formats: [String], $tags: [String], $limit: Int){
resources(
where: {
_or: [{name_contains: $keyword},{description_contains: $keyword}]
tags: {id_in: $tags}
languages: {id_in: $languages}
formats: {id_in: $formats}
}, sort: "name",limit:$limit) {
id
name
RTL
description
languages {
id
language
}
size
logo {
width
height
url
}
}
}
So I have been trying to do the same query with the count:
query resourcesConnection($keyword: String, $languages: [String], $formats: [String], $tags: [String]) {
resourcesConnection(
where: {
_or: [{name_contains: $keyword},{description_contains: $keyword}]
tags: {id_in: $tags}
languages: {id_in: $languages}
formats: {id_in: $formats}
}
) {
aggregate {
count
}
}
}
When I do I get errors because some of the strings are empty. For example, if a user hasn’t selected any tags, it will be empty and rely just not the keyword. This isn’t an issue for the first query, but for the count it doesn’t like it.
I have tried the custom schema but it doesn’t seem to provide the ability to replicate my initial query: Count with GraphQL - Strapi Developer Documentation
Any idea?