Is it possible to create array of images using GraphQL API? #248
-
Hey, In my project, I have created a Products collection that has an array of product variants and each product variant have a field of an array which have a relation to image collection. Everything works fine for payload Admin UI but I am not sure how can I create those images when creating a Product through GraphQL API. I found out about apollo-link-rest but couldn't figure out how to use it inside createProduct Mutation for images field(that's an array since multiple file upload isn't supported for upload yet). Is what I am trying to achieve possible with payload GraphQL API? Are there any plans for third party upload plugins that can support multiple uploads, with GraphQL API if possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@fabcodingzest you are awesome! You are doing some serious learning and skill development. I'm blown away. Sooo, the long and short of file uploading in GraphQL is that it's hard, and fairly nonsensical to do given the nature of GraphQL. For that reason, Payload does not support uploading files through GraphQL at this time. So, being that file uploads are actually just documents in a collection, to upload multiple files you'd need to do something like the following:
Does that make sense? / Answer your question? |
Beta Was this translation helpful? Give feedback.
@fabcodingzest you are awesome! You are doing some serious learning and skill development. I'm blown away.
Sooo, the long and short of file uploading in GraphQL is that it's hard, and fairly nonsensical to do given the nature of GraphQL.
For that reason, Payload does not support uploading files through GraphQL at this time.
So, being that file uploads are actually just documents in a collection, to upload multiple files you'd need to do something like the following:
create
endpoint, uploading files and creating documents accordingly