【发布时间】:2021-08-13 14:44:19
【问题描述】:
我是 graphql 的新手,无法找到简单问题的解决方案。
假设有 POJO:
class Book {
String title;
String authourName;
}
class Author {
String name;
Integer yearOfBirth;
}
type Book {
title: String
authourName: String
}
type Author {
name: String
yearOfBirth: String
}
我如何指定一个查询,我可以在 book.authorName = book.name 上加入 Book with Author:
BookWithAuthor(authorName: "xxx") {
title
authourName
yearOfBirth
}
?
【问题讨论】:
-
你不能在
Book中使用author: Author而不是authorName: String吗?然后查询将是{ title { author { name, yearOfBirth } } }。 -
但是如何在不将新数据保存到数据库的情况下指定关系
book.authorName = author.name?这只是我的实际问题的一个简单示例:我有很多表并希望将它们加入到一个 graphql 查询中