简体   繁体   English

IMDB API 请求 GraphQL 错误 'ClientError: 无法查询类型为“MainSearchEntity”的字段“图像”'

[英]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.

相关问题 您的 GraphQL 查询中出现错误:无法在“StrapiPropiedadesImagen”类型上查询字段“childImageSharp” - There was an error in your GraphQL query: Cannot query field “childImageSharp” on type “StrapiPropiedadesImagen” GraphQL / Relay架构无法在“CreateLinkPayload”类型上查询字段“store” - GraphQL/Relay Schema Cannot query field “store” on type “CreateLinkPayload” NestJs - Graphql 错误无法确定 GraphQL 输入类型<field> . 确保您的 class 已使用合适的装饰器进行装饰</field> - NestJs - Graphql Error Cannot determine a GraphQL input type for the <Field>. Make sure your class is decorated with an appropriate decorator 无法使用 Gatsbyjs 查询类型“查询”GraphCMS 上的字段“图像” - Cannot query field "image" on type "Query" GraphCMS with Gatsbyjs GraphQL /中继架构“无法查询字段...” - GraphQL/Relay Schema “Cannot query field…” Gatsby 和 WPGraphQL - 构建错误“无法在类型“查询”上查询字段“页面”” - Gatsby and WPGraphQL - Build Error "Cannot query field "pages" on type "Query"" GraphQL 查询返回错误“不能为不可为空的字段返回空值” - GraphQL query returns error "Cannot return null for non-nullable field" Gatsby GraphQL 中用于自定义查询的未知字段错误 - Unknow field error in Gatsby GraphQL for custom query 收到错误:类型为“查询” [GraphQL,Relay,React]的字段“用户”上的未知参数“ id” - Getting error : Unknown argument “id” on field “user” of type “Query” [GraphQL, Relay, React] Apollo客户端Graphql查询变量类型错误 - Apollo client Graphql query variable type error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM