const response = await fetch('https://example.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
operationName: 'fetchAuthor',
query: 'query fetchAuthor { author { id name } }',
variables: {},
}),
});
const data = await response.json();
<template>
<div class="textarea">
<textarea
name="card-textarea"
id=""
cols="30"
:rows="rows"
:placeholder="placeholder"
:value="value"
@input="$emit('input', $event.target.value)"
>
</textarea>
</div>
</template>
props: {
placeholder: {
type: String,
default: ""
},
rows: {
type: Number,
default: 5
},
value: {
type: String
}
}
this.$apollo.mutate({
mutation: gql`mutation createWrite($input: MyMutationInput!) {
createWrite(input: $input) {
write {
email
}
}
}`,
variables: {
input: {
data: {
name: data.name,
email: data.email,
title: data.title,
text: data.text,
doctor: data.doctor,
date: data.arrive,
polite: data.polite
}
}
}
})
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
HTTP.defaults.headers.common['Authorization'] = `Bearer ${token}`;