When I create a post with some text and an image. 2 image instances are created in the image table. First of all, I uploaded an image file on the server using curl, then the response of this curl request added to the post ->image field
Here is the curl request that is used to create the post:
await RNFetchBlob.fetch(
'POST',
'https://api.hypi.app/upload/hotspotz/images/',
{
Accept: 'application/json',
'Content-Type': 'multipart/form-data',
Authorization : "Authorization_Token" ,
'hypi-domain': 'hotspotz-v3.hotspotz.hotspotz.hotspotz.hypi.app',
},
formData,
);
Then the response of this curl request I pass in gql query:
const imageObj = {
name: imgResponse.name,
file:{
name: imgResponse.name,
directory: imgResponse.directory,
path: imgResponse.path,
isDirectory: imgResponse.isDirectory,
url: { path: imgResponse.url.path }
}
}
variables:{
img : imageObj,
description : desc,
userId : userId,
}
This is my query:
mutation CreatePost($description: String ,$userId: ID!, $img:ImageInputOpt ) {
upsert(
values: {
Post: [
{
description: $description
title:"new"
createdBy: {user: {hypi: {id: $userId}}}
images:[
$img
]
}
]
}
) {
id
}
}