Are you sure that formData is a string ?
image_path: formData,
(updated) I have this schema:
scalar Upload @scalar(class: "Nuwave\Lighthouse\Schema\Types\Scalars\Upload")
extend type Mutation {
createImageList(
id: ID!
category_id: String!
image_path: [Upload!]!
thumbnail: String!
label: String
description: String
tags: JSON
favorite_count: Int
): GalleryImageList @upsert
The React Client App:
const client = new ApolloClient({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
link: createUploadLink({
uri: process.env.NX_API_ENDPOINT
}),
cache: new InMemoryCache(),
cors: {
origin: [originPath],
credentials: true,
"Access-Control-Allow-Origin" : true,
methods: ['GET', 'POST'],
contentType: "application/json",
allowedHeaders: ['emexrevolarter']
}
});
Client Mutation schema:
API_MUTATION = gql`
mutation Entries($id: ID!,
$category_id: String!,
$image_path: [Upload!]!,
$thumbnail: String!,
$label: String,
$description: String,
$tags: JSON,
$favorite_count: Int) {
createImageList(
id: $id,
category_id: $category_id,
image_path: $image_path,
thumbnail: $thumbnail,
label: $label,
description: $description,
tags: $tags,
favorite_count: $favorite_count
){
id
category_id
label
description
updated_at
}
}
`;
Sending the multi-part form data including multiple files as formData:
SendMutation({variables: {
id: id,
category_id: category,
image_path: formData,
thumbnail: getThumbnail,
label: label,
description: description,
tags: getTags,
favorite_count: 0
}
I get the below error:
"debugMessage": "Array to string conversion",
"message": "Internal server error"
How do I make uploading files to grapghql work please?
Please or to participate in this conversation.