1

Is it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction?

I just found mutations for file uploading, but nothing for folder creation.

Thanks!

3
  • Do you want to create a subfolder on file upload or just create a subfolder on a volume? – Oli Nov 23 '20 at 16:56
  • Both ways are fine, though I would prefer to have the creation separate from uploading. And also how to read available folders. Thanks – Matthias Redl-Mann Nov 23 '20 at 19:02
  • @Oli can you still help me with this? – Matthias Redl-Mann Dec 16 '20 at 7:54
3

Currently, there’s no direct way of doing this. You can pass an existing folder ID but you can’t create folders on the fly.

However, you can create folders via an asset field (with dynamic path) attached to an entry type so there is an option that could work if you really need this done.

Create a section/entry type that has two fields, an Asset field with a dynamic path set to {folderPath} and a plain text one called folderPath.

It would then happen in three steps:

  1. Mutate the Asset and get its ID back
  2. Mutate an entry in your new entry type where you set the Asset field to your (just uploaded) asset ID and set folderPath to whatever path you need, save and get its id back. This would create a folder and move your asset to it.
  3. Delete the entry you’ve just created via a mutation using its id.

I know it’s not straight forward but if you really need to make it work, this would do the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.