【发布时间】:2017-02-15 13:24:47
【问题描述】:
我需要帮助以 GraphQL 语法将参数传递给集合/连接/数组。
我只是在学习它,在http://graphql.org/swapi-graphql/玩 SWAPI
我可以将 id 参数传递给单个类型,如下所示:
query getANewHope {
film(id: "ZmlsbXM6MQ==") {
id
title
}
}
但我不知道如何查询集合/连接的结果
query starships {
allStarships(id: "c3RhcnNoaXBzOjI=") { # this doesn't work
edges {
node(id: "c3RhcnNoaXBzOjI=") { # ...nor this.
id
}
}
}
}
我想查询集合,因为我想将“新希望中的所有星际战斗机类型舰船”之类的两个想法联系起来?
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\"."
}
}
【问题讨论】:
标签: graphql