javascript - ScriptTagInput 类型的变量 $input!提供了无效值
问题描述
如何在 JS 文件中正确地进行突变?
这是我目前在我的 JS 文件中的查询:
const src = "https://faqapp.test/scripttags/app.js";
axios({
url: "/app/graphql",
method: "post",
data: {
query: `mutation scriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
}
userErrors {
field
message
}
}
}`,
variables: {
input: {
src
}
},
headers: {
"Content-Type": "application/json"
}
}
})
.then(res => {
console.log(res.data);
})
.catch(err => {
console.log(err.message);
});
我正在尝试执行的查询(在 graphql 资源管理器中有效):
mutation scriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
}
userErrors {
field
message
}
}
}
查询变量
{
"input": {
"src": "https://faqapp.test/createbannertemplate.js"
}
}
我是 graphql 的新手,所以我可能缺少一些非常简单的东西。这更像是我正在开发的 shopify 应用程序。
谢谢,希望这不是太模糊。
解决方案
推荐阅读
- amazon-web-services - 使用 SSH 和 pem 文件的 EC2 连接返回 Permission denied (publickey)
- python - x 轴为 1d Numpy 数组且 y 轴为 2d Numpy 数组时的散点图
- sql - 必须声明已经声明的标量变量“”
- django - django 表单保存但不重定向
- excel - 将超链接添加到工作表的最快方法是什么?
- amazon-web-services - AWS Systems Manager - 会话管理器和运行命令“文档过程意外失败”
- postman - 如何使用 Postman 的 CookieJar 清除 HTTPS cookie
- neo4j - 在图形数据库(ArangoDB)中表示日期的正确方法是什么?
- c# - 如何将数据附加到循环列表中?
- javascript - 将列表中按钮的值设置为“是”