cap*_*uch 5 javascript graphql
我有一个块试图找出查询条件的语法,这似乎很常见。
下面的 typedef 以一对多(作者)关系存储代表作者的代理的 ID 值。我想在从作者架构中获取详细信息的同时提取代理的名称。
type Author {
id: ID!
firstName: String
middleInitial: String
lastName: String
posts: [Post]
agent: ID
Run Code Online (Sandbox Code Playgroud)
}
所以封闭查询(返回所有作者的列表)看起来像这样:
{
authors {
firstName
lastName
agent
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我代理的 ID。如何使用相同的查询从类似于上述类型的 typedef 中获取代理的名称?
type Agent {
id: ID!
name: String
}
type Author {
id: ID!
firstName: String
middleInitial: String
lastName: String
posts: [Post]
agent: Agent
}
// Query
{
authors {
firstName
lastName
agent {
name
}
}
}
Run Code Online (Sandbox Code Playgroud)