0

I use the following mutation for inserting an image into a post.

mutation MyMutation {
  createPost(
    data: {title: "", excerpt: "", content: "", postid: "", featuredImage: {create: {fileName: "", handle: ""}}, author: {connect: {Author: {email: ""}}}}
  )
}

But I don't know what the handle of the image should be. In react what should be the value of handle attribute of the featured image?

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
Frecoder
  • 23
  • 8

1 Answers1

1

My name is Own, and I am part of the support team at Hygraph. To upload assets you need to use the upload endpoint, once you upload an asset we return the Id of the asset entry that was created, from there, you can use that asset Id returned to connect it to entries :)

Here is the link to the docs: https://hygraph.com/docs/api-reference/content-api/assets#upload-by-file

The createAsset mutation should not be used to create assets. Please feel free to reach out to us if you have any questions using the in app chat tool. We are highly responsive and always happy to help

  • But all these FormData class and other thing are from node-fetch package. There it is mentioned that most extension file only work. This dicussion seems to be increasing. So if you name the chat tool we shall continue this there. – Frecoder May 27 '23 at 01:25
  • When I tried using normal fetch I am getting page not found error – Frecoder May 27 '23 at 01:39