IMDB API请求GraphQL错误'ClientError: Cannot query field &quo



我正在尝试获得与搜索词'Africa'匹配的十大电影名称推荐,基于这里的IMDB API演示https://developer.imdb.com/documentation/api-documentation/sample-queries/search/?ref_=side_nav。

我需要查询返回电影id,标题,图像海报和拍摄地点。

然而,当我运行下面的图形查询时,我得到错误'ClientError: Cannot query field "Image"输入"mainsearchentity"。无法查询字段filminglocation;on type "MainSearchEntity";

当我从脚本中删除代码Image { url } FilmingLocation { text }时,查询工作正常。

下面的查询可能有什么问题?

如何在查询中包含海报图像和拍摄地点?

谢谢!


{
# Get the top 10 name recommendations that match the search term Africa.
mainSearch(
first: 10
options: {
searchTerm: "Africa"   
isExactMatch: false   
type: TITLE      
includeAdult:false,
}
) {
edges {
node {
entity {
# For returned Names, get me the id, name text, image, year, country
... on Name {
id
nameText {
text
}
}
Image {
url
}
FilmingLocation {
text
}
}
}
}
}
}

假设引起您麻烦的两个字段称为posterImage和filmingLocation(通常字段名称是在camelCase),我猜您的查询应该是:

query {
# Get the top 10 name recommendations that match the search term Africa.
mainSearch(
first: 10
options: {
searchTerm: "Africa"
isExactMatch: false
type: TITLE
includeAdult:false,
}
) {
edges {
node {
entity {
# For returned Names, get me the id, name text, image, year, country
... on Name {
id
nameText {
text
}
image {
url
}
filmingLocation {
text
}
}
}
}
}
}
}

问题似乎是这两个字段不在MainSearchEntity中。希望能有所帮助!

修复:

显示图像海报字段是'primaryImage'而不是image。

下面是工作代码:


{
# Get the top 10 name recommendations that match the search term Jennifer.
mainSearch(
first: 10
options: {
searchTerm: "Jennifer"   
isExactMatch: false   
type: TITLE      
includeAdult:false,
}
) {
edges {
node {
entity {
# For returned Names, get me the id, name text, image, year, country
... on Title {
id
titleText {
text
}
primaryImage {
url
}
filmingLocations(first:1) {
edges{
node{
text
}
}
}
}
}
}
}
}
}

相关内容

最新更新