嵌套突变似乎在 Lighthouse 3.7 中不起作用
Nested mutations don't seem to work in Lighthouse 3.7
我正在尝试在 Lighthouse 3.7 中设置模式/Laravel 5.8
我想要实现的是:
用户应该能够创建列表。
User 和 Clist 之间存在一对多关系。
我正在尝试按照 here.
中的描述实施嵌套突变
我已经实现了 "query" 部分并且工作正常。
但是当我在 GraphQL Playground 中测试 createClist 突变时,我得到这个错误:
"debugMessage": "Array to string conversion",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
...
而且我不知道我做错了什么。
这是我的代码:
type Mutation {
createClist(input: CreateClistInput! @spread): Clist @create
}
input CreateClistInput {
name: String!
description: String
starred: Boolean
user: CreateUserRelation!
ctags: CreateCtagRelation
}
input CreateUserRelation {
connect: ID!
}
input CreateCtagRelation {
create: [CreateCtagInput!]
connect: [ID!]
sync: [ID!]
}
input CreateCtagInput {
name: String!
}
这是 GraphQL Playground 的屏幕截图:
使用 @spread
指令时,需要对模型中的关系进行类型提示。
摘自 docs 有以下示例:
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Post extends Model
{
// WORKS
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
// DOES NOT WORK
public function comments()
{
return $this->hasMany(Comment::class);
}
}
Lighthouse 使用类型提示来确定它应该如何处理关系。
我正在尝试在 Lighthouse 3.7 中设置模式/Laravel 5.8 我想要实现的是: 用户应该能够创建列表。 User 和 Clist 之间存在一对多关系。 我正在尝试按照 here.
中的描述实施嵌套突变我已经实现了 "query" 部分并且工作正常。 但是当我在 GraphQL Playground 中测试 createClist 突变时,我得到这个错误:
"debugMessage": "Array to string conversion",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
...
而且我不知道我做错了什么。
这是我的代码:
type Mutation {
createClist(input: CreateClistInput! @spread): Clist @create
}
input CreateClistInput {
name: String!
description: String
starred: Boolean
user: CreateUserRelation!
ctags: CreateCtagRelation
}
input CreateUserRelation {
connect: ID!
}
input CreateCtagRelation {
create: [CreateCtagInput!]
connect: [ID!]
sync: [ID!]
}
input CreateCtagInput {
name: String!
}
这是 GraphQL Playground 的屏幕截图:
使用 @spread
指令时,需要对模型中的关系进行类型提示。
摘自 docs 有以下示例:
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Post extends Model
{
// WORKS
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
// DOES NOT WORK
public function comments()
{
return $this->hasMany(Comment::class);
}
}
Lighthouse 使用类型提示来确定它应该如何处理关系。