我正在寻找 Laravel Lighthouse 的文档,我看到了两种类型的突变。
- 包含字符串的突变
input:
(在此处找到)
mutation {
createPost(input: { # <-- the "input:" I'm talking about
title: "My new Post"
author: {
connect: 123
}
}){
id
author {
name
}
}
}
还有另一个没有(在这里找到)的突变input:
mutation CreateTaskWithNotes {
createTask( # <-- no "input:" here
id: 45
name: "Do something"
notes: [
{
content: "Foo bar",
link: "http://foo.bar"
},
{
content: "Awesome note"
}
]
) {
id
}
}
我的问题是:如何在不input:
工作的情况下获得突变?
我尝试从文档中复制(修改)示例。但是如果我写一个这样的突变:
type Mutation {
createTask(input: CreateTaskInput! @spread): Task! @create
}
当我尝试省略input:
时,graphql-playground 抱怨:“需要CreateTaskInput类型的字段createTask参数输入,但未提供”
现在我尝试将架构更改为:
type Mutation {
createTask(CreateTaskInput! @spread): Task! @create
}
但随后服务器给出了一个ParseException
.
我确实更喜欢没有的语法,input:
因为它的重复性要少得多。有人可以帮忙吗?