[英]IMDB API request GraphQL Error 'ClientError: Cannot query field "Image" on type "MainSearchEntity"'
I'm trying to get the top 10 movie name recommendations that match the search term 'Africa', based on the IMDB API demo here https://developer.imdb.com/documentation/api-documentation/sample-queries/search/?ref_=side_nav .我正在尝试根据 IMDB API 演示获得与搜索词“非洲”匹配的前 10 部电影名称推荐https://developer.imdb.com/documentation/api-documentation/sample-queries/search/ ?ref_=side_nav 。
I need the query to return the movie id, title, image poster and filming location.我需要查询返回电影 ID、标题、图片海报和拍摄地点。
However, when I run the graph query below, I get the error 'ClientError: Cannot query field "Image" on type "MainSearchEntity".|Cannot query field "FilmingLocation" on type "MainSearchEntity"."但是,当我运行下面的图形查询时,出现错误“ClientError:无法查询类型为“MainSearchEntity”的字段“Image”。|无法查询类型为“MainSearchEntity”的字段“FilmingLocation”。
The query works fine when I remove the code Image { url } FilmingLocation { text }
from the script.当我从脚本中删除代码
Image { url } FilmingLocation { text }
时,查询工作正常。
What could be the problem with the query below?下面的查询可能有什么问题?
How do I include the poster image and filming location in the query?如何在查询中包含海报图片和拍摄地点?
Thanks!谢谢!
{
# 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
}
}
}
}
}
}
Assuming the two fields that are causing you trouble are called posterImage and filmingLocation (usually field names are in camelCase), I guess your query should be:假设给您带来麻烦的两个字段称为 posterImage 和 filmingLocation(通常字段名称采用驼峰式命名),我猜您的查询应该是:
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
}
}
}
}
}
}
}
The problem seems to be that the two fields were not inside the MainSearchEntity.问题似乎是这两个字段不在 MainSearchEntity 中。 Hope it helps!
希望能帮助到你!
Fixed it:修复:
Turns out the image poster field is 'primaryImage' not Image.原来图像海报字段是“primaryImage”而不是图像。
Here's the working code:这是工作代码:
{
# 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
}
}
}
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.