I'm using gatsby-source-graphql with Strapi content, I have a query like this:
{
regions(sort: "sortId:asc", where: { shops: { published: true } }) {
id
name
shops(sort: "sortId:asc", where: { published: true }) {
id
published
}
}
}
it works fine in both strapi/graphql explorer and gatsby http://localhost:8000/___graphql? one.
but when I compile I'm getting this error
Syntax Error: Expected Name, found String "shops"
GraphQL request (7:41)
6: }
7: regions(sort: "sortId:asc", where: {"shops":{"published":true}}) {
just want to point out, that the query in my code is like the one above, and not like the error one that has shops in double quotes,
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-4690 CPU @ 3.50GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.3.1 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/local/bin/python
Browsers:
Chrome: 74.0.3729.169
Firefox: 66.0.3
Safari: 12.1.1
npmPackages:
gatsby: ^2.8.5 => 2.8.5
gatsby-image: ^2.1.2 => 2.1.2
gatsby-plugin-manifest: ^2.1.1 => 2.1.1
gatsby-plugin-offline: ^2.1.1 => 2.1.1
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-plugin-sharp: ^2.1.3 => 2.1.3
gatsby-source-filesystem: ^2.0.38 => 2.0.38
gatsby-source-graphql: ^2.0.18 => 2.0.18
gatsby-transformer-sharp: ^2.1.21 => 2.1.21
npmGlobalPackages:
gatsby-cli: 2.6.4
Hello @violabg!
Could you paste your code where you use this query? It sounds like either variables or the query is passed somehow wrong and it runs with quotes in it.
Thank you! :purple_heart:
Hi thanks,
I'm not passing any variables, this is the code.
export const query = graphql`
query {
ge {
tags(sort: "sortId:asc") {
id
value
}
regions(sort: "sortId:asc", where: { shops: { published: true } }) {
id
name
bgImage {
url
imageFile {
...bgImage
}
}
shops(sort: "sortId:asc", where: { published: true }) {
id
published
name
country
lat
long
flag {
url
imageFile {
...flagImage
}
}
tags {
value
}
}
}
}
}
`;
P.S.
If I remove the "where" filter it works
I'm running into this too. It seems like when the graphql compiles, it forces the where value to string, instead of JSON, or something like that.
Edit: I think this is related to issues #12856 and #11710 -- I'm not familiar enough w/ graphql to fully understand these issues, but seems to be a problem related to relay-compiler.
Same issue... I cant use a where filter inside the gatsby code because the query doesn't work. Any solution?
houses(sort: "created_at:DESC", limit: 4, where: {id: 1})
I have found a workaround for this issue. Perhaps this will be of help to others.
The following fails:
blah(where: {id : $blah_id}) in the query, with { "blah_id" : "5" } passed to context in createPage`
The following works:
blah(where: $blah_id_json) in the query, with { "blah_id_json" : { "blah_id" : "5" }} passed to context in createPage`
Your proposal is not valid for me. I'm running an static query:

It shows me this error:
Syntax Error: Expected Name, found String "direct_sale"

If I run this query in the graphql editor, everything works fine.... Any idea?
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
I'm having this issue as well. Is there any sort of fix for this?
As far as I can tell it looks like it turns the "JSON like" where query into an actual JSON string, meaning it adds quotes around the property names or something like that.
@abv 's suggestion works, but is not really something I want to be doing if at all possible. I'd like to get this working as it should, anyone that can help with this?
If possible, could you provide a link to a repo to reproduce this error? Thanks!
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community!
stil not working
Most helpful comment
@abv 's suggestion works, but is not really something I want to be doing if at all possible. I'd like to get this working as it should, anyone that can help with this?