graphql - Strapi graphql 突变
问题描述
我正在使用 strapi 作为无头 CMS
我创建了一个客户内容类型并安装了 graphql 插件。
我正在尝试在 graphql 游乐场中创建一个突变以创建一个新客户
mutation createCustomer($username: String!, $email: String, $password: String){
createCustomer(username: $username, email: $email, password: $password){
_id username email password
}
}
我在查询变量中传递用户名等
{ "username": "user1" }
{ "email": "User1@test.com" }
{"password":"123456"}
我收到错误
"message": "Unknown argument \"username\" on field \"createCustomer\" of type \"Mutation\".",
如果我查看文档,它看起来像。
如何编写突变以创建新客户
解决方案
该错误表明在突变的查询组件中缺少对客户类型的引用。
另外,我相信您缺少“输入:”和“数据:”。我知道使用 createUser 时需要这些。
举例:
mutation createCustomer($username: String!, $email: String, $password: String) {
createCustomer(
input: { data: { username: $username, email: $email, password: $password } }
) {
customer {
id
username
email
password
}
}
}
推荐阅读
- c - for 循环仅迭代在 scanf 之后编写的 printf 一次
- android - 如何在 webview 中打开相机?
- python - kmeans++的向量化实现
- maven - 无法确定 pom.xml 的全局设置
- oracle - Entity Framework db first:状态机器关联
- python-docx - 在 python-docx 中创建 word 字段以从 word 文档的第 2 页自动生成页脚(例如 # Page / # Total Pages)?
- excel - 用于匹配字符串并复制它的 VBA 代码
- typo3 - TYPO3:在 TCA 中使用 ###PAGE_TSCONFIG_ID### 和 addRecord
- machine-learning - spark 1.6 中用于高基数分类变量的散列编码器
- freertos - 低优先级任务需要先启动 FreeRTOS