Graphql Query
Is there a way to query for a specific folder with Graphql?
This query gets me back a specific file:
{
allCloudinaryMedia(filter: {id: {eq: "7f7af989-f796-5120-b9f6-5d208c3c5ec9"}}) {
nodes {
url
}
}
}
And this one gets me back all files:
{
allCloudinaryMedia {
nodes {
url
id
}
}
}
Thanks!
-
Hi Daniel,
Cloudinary currently doesn't have direct support for GraphQL, but if you share with us what library/framework you're using we may be able to take a look at how it could work.
Best regards,
Aleksandar
0 -
I managed this by filtering my query using the public_id of the folder with the images I was interested in. You can use a glob (global) query and give it a wild card (*) to select everything within that folder e.g.:
{
allCloudinaryMedia(filter: {public_id: {glob: "top-level-directory/directory-with-images/*"}}) {
nodes {
url
}
}
}FYI I was using Gatsby with the gatsby-source-cloudinary plugin. I suggest you run a general query to see what your public_id looks like, then base your wildcard filter on that.
0 -
That is a great approach, Stuart. Thanks for sharing.
Daniel, please try Stuart's example and let us know if that works for you too.0
Post is closed for comments.
Comments
3 comments