-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defineQuery with multiple requests only retrieves the first request #1765
Comments
Alright. So I did a test using suspense and on the ssr page and i got the expected results. My best guess is that sanity takes the each of the queries individually and doesn't wait for the all to resolve before sending back data. Thus, when the first one resolves it gets sent back and then ssr proceeds thinking it has everything it needs - which is why the remaining query result aren't included. throwing in suspense it will actually give me all the results as they come through the readablestream returned by sanity query. still not sure if thats expected behavior or not. as far as a solution goes it seems suspense makes the most sense. |
It should be sending all the data every time, I think what we have here is a cache problem. You could bump the |
In my project I have content from 4 documents I need to retrieve on a single page. When using the vision tool I can correctly retrieve all the documents. When using defineQuery() and actually running the query I am only ever getting results for the first query and none of the others.
query:
export const multipleQueries = defineQuery(
{ 'a': *[_type == "aDocument"][0], 'b': *[_type == "bDocument"][0..4], 'c': *[_type == "cDocument"][0..4], 'd: *[_type == "dDocument"][0..4], }
);when running the above I get results for 'a' but everything else is an empty array.
when i remove 'a' i get results for 'b' but everything else is an empty array.
likewise for the remainder.
To Reproduce
Expected behavior
I should receive content for ALL the queries as I do in when using the vision tool and not just the first query
Which versions of Sanity are you using?
using react 18, sanity 3.44, next-sanity 9.3.10
What operating system are you using?
MacOS sonoma 14.5
Which versions of Node.js / npm are you running?
npm -v && node -v
10.2.0
v21.7.1
The text was updated successfully, but these errors were encountered: