This query in grahiql
works:
mutation {
addSkill(id:\"5\",name:\"Javascript\",level:1,type:\"frontend\") {
status
id
name
leve
Found the problem.
mutation
"
after $name
Update - a cleaner version:
axios
.post(config.apiendpoint, {
query: `mutation {
addSkill(id:"${id}", name:"${this.form.name}", level:${parseFloat(this.form.level)}, type:"${this.form.type}") {
status
id
name
level
type
}
}
`,
}).then().catch()
Here's the working request for reference.
axios
.post(config.apiendpoint, {
query: `
mutation addSkill($id:String!, $name:String!, $level:Float!, $type:String!) {
addSkill(id:$id, name:$name, level:$level, type:$type) {
status
id
name
level
type
}
}
`,
variables: {
id: String(id),
name: this.form.name,
level: parseFloat(this.form.level),
type: this.form.type,
},
})
.then(res => console.log(res))
.catch(err => console.log(err))