问题描述
我在graphql中有以下突变(创建新客户-类似于用户注册):
mutation {
createCustomer(
input: {
firstname: "Bob"
lastname: "Loblaw"
email: "[email protected]"
password: "b0bl0bl@w"
is_subscribed: true
}
) {
customer {
firstname
lastname
email
is_subscribed
}
}
}
它是从Magento 2.4文档中复制并粘贴的:https://devdocs.magento.com/guides/v2.4/graphql/mutations/create-customer.html
当我尝试拨打其他突变时,我遇到了相同的错误:
{
"errors": [
{
"message": "Schema is not configured for mutations.","locations": [
{
"line": 1,"column": 1
}
],"stack": [
"GraphQLError: Schema is not configured for mutations."," at getoperationRoottype (/home/marcin/projects/a24store/frontend/node_modules/graphql/utilities/getoperationRoottype.js:28:13)"," at executeOperation (/home/marcin/projects/a24store/frontend/node_modules/graphql/execution/execute.js:210:61)"," at executeImpl (/home/marcin/projects/a24store/frontend/node_modules/graphql/execution/execute.js:104:14)"," at execute (/home/marcin/projects/a24store/frontend/node_modules/graphql/execution/execute.js:64:35)"," at /home/marcin/projects/a24store/frontend/node_modules/express-graphql/index.js:152:16"," at processticksAndRejections (internal/process/task_queues.js:97:5)"
]
}
],"extensions": {}
}
我的Magento 2设置正确,因为其他查询(例如用于获取产品,类别等的查询)可以正常工作,并且给出了正确的答案。 我正在使用Magento 2.4版本的全新安装。
Magento文档甚至没有提及在后端代码中进行更改。但是我发现了这样的东西:https://www.mobelop.com/blog/magento2-graphql-tips-and-tricks/。有一个称为“在Magento GraphQL中启用突变”的部分。
所以我认为我应该在某些模块中扩展或更改graphql模式。但我不知道在哪里。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)