连接子结果的 GraphQL 参数
GraphQL arguments to connection sub results
我需要帮助以 GraphQL 语法将参数传递给 collections/connections/arrays。
我只是在学习它,在 http://graphql.org/swapi-graphql/
玩 SWAPI
我可以将 id 参数传递给单个类型,如下所示:
query getANewHope {
film(id: "ZmlsbXM6MQ==") {
id
title
}
}
但是我不知道怎么查询一个collection/connection
的结果
query starships {
allStarships(id: "c3RhcnNoaXBzOjI=") { # this doesn't work
edges {
node(id: "c3RhcnNoaXBzOjI=") { # ...nor this.
id
}
}
}
}
我想查询集合,因为我想将这两个想法联系起来,例如 "All Starfighter type ships in A New Hope"?
query filmStarships {
film(id: "ZmlsbXM6MQ==") {
title
starshipConnection { #How to limit this? I can't use (starshipClass: "Starfighter") here...
edges {
node { # ...nor here..
starshipClass # ...nor here.
}
}
}
}
}
query starships2 {
starship (id: "c3RhcnNoaXBzOjI=") { # This doesn't work either
id # even without an arugment abovce, it says "Unknown argument \"id\" on field \"node\" of type \"StarshipsEdge\"."
}
}
您要求的参数必须在架构中实现。 SWAPI 不公开要按 starshipClass
过滤的参数。单击 GraphiQL window 右上角的 Docs
以浏览提供的架构。
如果您正在实施自己的架构,那么在解析器中的 starshipClass
上添加过滤器会非常容易。
我需要帮助以 GraphQL 语法将参数传递给 collections/connections/arrays。
我只是在学习它,在 http://graphql.org/swapi-graphql/
玩 SWAPI我可以将 id 参数传递给单个类型,如下所示:
query getANewHope {
film(id: "ZmlsbXM6MQ==") {
id
title
}
}
但是我不知道怎么查询一个collection/connection
的结果query starships {
allStarships(id: "c3RhcnNoaXBzOjI=") { # this doesn't work
edges {
node(id: "c3RhcnNoaXBzOjI=") { # ...nor this.
id
}
}
}
}
我想查询集合,因为我想将这两个想法联系起来,例如 "All Starfighter type ships in A New Hope"?
query filmStarships {
film(id: "ZmlsbXM6MQ==") {
title
starshipConnection { #How to limit this? I can't use (starshipClass: "Starfighter") here...
edges {
node { # ...nor here..
starshipClass # ...nor here.
}
}
}
}
}
query starships2 {
starship (id: "c3RhcnNoaXBzOjI=") { # This doesn't work either
id # even without an arugment abovce, it says "Unknown argument \"id\" on field \"node\" of type \"StarshipsEdge\"."
}
}
您要求的参数必须在架构中实现。 SWAPI 不公开要按 starshipClass
过滤的参数。单击 GraphiQL window 右上角的 Docs
以浏览提供的架构。
如果您正在实施自己的架构,那么在解析器中的 starshipClass
上添加过滤器会非常容易。