Laravel lighthouse graphql 通过关系表值查询
Laravel lighthouse GraphQL 中是否可以通过关系表值进行查询? 例如,我定义了两种类型。
type Translation {
id: ID!
form_group_id: Int!
group: Group @hasOne
translation_key: String!
lv: String
en: String
ru: String
}
type Group {
id: ID!
name: String!
translations: [Translation]! @hasMany
}
我想按组名称查询。 下面的代码只是这个想法的一个例子。 translation(group.name: String! @eq): Translation @find
我有一个想法,这可以通过自定义解析器实现,但是有没有办法使用内置的雄辩解析器?
Is it possible in Laravel lighthouse GraphQL to query by relation table values?
For example, I have defined two types.
type Translation {
id: ID!
form_group_id: Int!
group: Group @hasOne
translation_key: String!
lv: String
en: String
ru: String
}
type Group {
id: ID!
name: String!
translations: [Translation]! @hasMany
}
and I want to query by group name.
The code below is just an example of the idea.translation(group.name: String! @eq): Translation @find
I have an idea that this, can be possible with custom resolver, but is there a way using built in eloquent resolvers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然这是一个实验性功能,但您可以使用 复杂的 where 条件。这将允许您通过其关系属性获取任何类型。我们在我们的应用程序中使用它,对于我们的使用,这按预期工作:)
Event tho this is an experimental feature, you can use complex where conditions. This will allow you to fetch whatever type by its relation attributes. We use it on our application, and for the use we have, this is working as expected :)