【发布时间】:2019-06-22 22:30:43
【问题描述】:
当我手动编写突变查询(在 graphql 插件中)时,它正在工作:
mutation {
createExam(input: {
data: {
name: "myName"
desription: "ggg"
questions: [{gf: "hello"}]
time: 2
subjects: ["5c468e2d61670b25b46ccdfe"]
}
}) {
exam {
name
desription
time
}
}
}
但是,如果我对其进行编码并传递完全相同的数组,我会得到一个完全相同的对象数组,我会得到 [null, null]
let parsedQuestion = [{gf: "hello"}];
const response = await strapi.request('POST', '/graphql', {
data: {
query: `mutation {
createExam(input: {
data: {
name: "` + examInfo.newExamName + `"
desription: "` + examInfo.newExamDescription + `"
time: ` + Number(examInfo.newExamTime) + `,
questions: `+ parsedQuestion + `,
subjects: ["` + this.state.modalSubject._id + `"]
}
}) {
exam {
name
desription
time
questions
}
}
}`
}
怎么可能?这可能是一个错误吗?我也尝试过使用 JSON.stringify 但后来出现错误,甚至没有发生突变
提前非常感谢
【问题讨论】: