考虑到以下Apollo Server GraphQL模式,我希望将其分解为单独的模块,因此不想在根查询架构下使用作者查询。我想将其分离。所以我添加了另一层称为authorQueries,然后将其添加到根查询中。
type Author {
id: Int,
firstName: String,
lastName: String
}
type authorQueries {
author(firstName: String, lastName: String): Author
}
type Query {
authorQueries: authorQueries
}
schema {
query: Query
}
我尝试了以下操作...你可以看到在指定作者函数之前,authorQueries被添加为另一层。
Query: {
authorQueries :{
author (root, args) {
return {}
}
}
}
当在Graphiql中进行查询时,我还添加了额外的层级..
{
authorQueries {
author(firstName: "Stephen") {
id
}
}
}
我遇到了下面的错误。
"message": "Query.authorQueries 的解析函数未返回值。",
authorQueires
,productQueries
...等等或者按照授权的意思。我认为这不错,但很少见。 - Tokenyet