I want to fetch multiple collections at once, right now my implementation is to fetch each collection in a different promise and then waiting on them all. Is there a way to make a single request that queries multiple collections at once?
There's no way to do that right now, awaiting all of your queries is the right way to do it right now, have you had any issues with that approach?
You can use the GraphQL api for that.
In this example, i'm fetching bot "posts" and "categories" using 1 api call.
Ohh derp, I was thinking of the local API only...yes this is the way if you're using graphql
if you're using REST you can create a custom endpoint for yourself
yes haha, with the rest api it's quite difficult to do, with the exception of creating your own endpoint ofcourse.
Right now I am using the local api to fetch every collection that has an url, to make sure the new one is unique. There is nothing wrong with it functionality wise, but it seems inefficient because i fetch every collection separate. Is graphql also intended to be used for internal use? I am making the request from inside payload.
what are your collections? Could you not just prefix the document slug with the collection type?
Also, have you seen the nested docs plugin:
https://github.com/payloadcms/plugin-nested-docsStar
Discord
online
Get help straight from the Payload team with an Enterprise License.