【发布时间】:2020-05-11 12:11:44
【问题描述】:
我正在寻找 Laravel Lighthouse 的文档,我看到了两种类型的突变。
- 包含字符串
input:(found here) 的突变
mutation {
createPost(input: { # <-- the "input:" I'm talking about
title: "My new Post"
author: {
connect: 123
}
}){
id
author {
name
}
}
}
还有一个没有input:(found here)的突变
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 参数 input 是必需的,但不是提供”
现在我尝试将架构更改为:
type Mutation {
createTask(CreateTaskInput! @spread): Task! @create
}
但随后服务器给出了ParseException。
我确实更喜欢没有input: 的语法,因为它的重复性要少得多。
有人可以帮忙吗?
【问题讨论】:
标签: laravel graphql laravel-lighthouse