【发布时间】:2019-11-21 16:54:34
【问题描述】:
我正在尝试在 Lighthouse 3.7/Laravel 5.8 中设置架构 我想要实现的是: 用户应该能够创建列表。 User 和 Clist 之间存在一对多关系。 我正在尝试按照here 的描述实现嵌套突变。
我已经实现了“查询”部分,它工作正常。 但是当我在 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 的截图:
【问题讨论】:
-
你能展示你的模型吗?使用 Lighthouse
@spread指令时,需要键入提示关系的返回类型。 lighthouse-php.com/3.7/eloquent/… -
就是这样!有用。非常感谢!
-
我把它作为答案发布了,所以你可以接受它:)
标签: laravel graphql laravel-lighthouse