I am getting the following error on a graphql query in a gatsby website where I am fetching data from the Strapi CMS.
Syntax Error: Expected Name, found String "" gatsby
Here is the code:
export const Query = graphql`
{
source {
people(where: {isSupport: true}) {
name
photo {
url
}
surname
isSupport
}
}
`
With the above query, I am trying to fetch people that are part of the support team but I get this error Syntax Error: Expected Name, found String "isSupport"
The above code works fine on the Graphql explorer. I then thought because the query is in a template string I should change my code as follows.
export const Query = graphql`
{
source {
people(where: {${isSupport}: true}) {
name
photo {
url
}
surname
isSupport
}
}
`
With the above code, I still could not get the desired results.
Looking closer into the graphql explorer I noticed that the where
filter takes a JSON object so I converted my code as follows:
export const Query = graphql`
{
source {
people(where: {"isSupport": true}) {
name
photo {
url
}
surname
isSupport
}
}
`
With the above code, I still could not get the desired results.