Hi,
I made it work to show content from Hygraph, but how can I add content to hygraph using a form in Astro?
This is my current function, but I don't know how to send the info to Hygraph.
const createCategory = async (title: string, categoryType: string) => {
const response = await fetch(hygraphEndpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: `mutation createCategory($title: String!, $categoryType: String!) {
createCategory(title: $title, categoryType: $categoryType) {
id
title
categoryType
}
}`,
variables: {
input: {
title,
categoryType,
},
},
}),
});
const json = await response.json();
return json.data.createCategory as Category;
};