Graphql 语法错误:应为名称,找到字符串&引用;盖茨比与格拉普

Graphql 语法错误:应为名称,找到字符串&引用;盖茨比与格拉普,graphql,gatsby,strapi,Graphql,Gatsby,Strapi,我在盖茨比网站上的graphql查询中遇到以下错误,我从Strapi CMS获取数据 语法错误:应为名称,找到字符串“”gatsby 代码如下: export const Query = graphql` { source { people(where: {isSupport: true}) { name photo { url } surname isSupport } }

我在盖茨比网站上的graphql查询中遇到以下错误,我从Strapi CMS获取数据

语法错误:应为名称,找到字符串“”gatsby

代码如下:

export const Query = graphql`
 {
   source {
     people(where: {isSupport: true}) {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`
在上面的查询中,我试图获取属于支持团队的人员,但出现以下错误语法错误:预期名称,找到字符串“Isupport”

上述代码在Graphql资源管理器上运行良好。然后我想,因为查询是在一个模板字符串中,所以我应该如下更改代码

export const Query = graphql`
 {
   source {
     people(where: {${isSupport}: true}) {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`
使用上面的代码,我仍然无法获得期望的结果

仔细查看graphql资源管理器,我注意到
where
过滤器采用JSON对象,因此我将代码转换如下:

export const Query = graphql`
 {
   source {
     people(where: {"isSupport": true}) {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`

使用上面的代码,我仍然无法获得所需的结果。

您是否尝试过以下方法:

export const Query = graphql`
 query ($isSupport: Boolean){
   source {
     people(where: {$isSupport: true}) {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`
您没有在查询构造函数中定义变量类型(
$isSupport:String

此外,我不熟悉
where
filter。以下措施也应该奏效:

export const Query = graphql`
 query ($isSupport: Boolean){
   source (people: {isSupport: {eq: $isSupport}}) {
     people {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`
上面的代码段将过滤所有
,这些源包含
人员。Isupport
属性等于通过上下文传递的值

如果未从上下文传递任何值,请直接检查该值:

export const Query = graphql`
 {
   source (people: {isSupport: {eq: true}}) {
     people {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`
或应用
其中
过滤器:

export const Query = graphql`
 {
   source {
     people(where: {isSupport: true}) {
       name
       photo {
         url
       }
       surname
       isSupport
     }
  }
`

最简单的:将筛选器/where值
where:{isSupport:true}
传递到$where。。。只有最后一个会起作用:D其他参数更改不会更改结果1:不允许属性名称的变量;第二个$isSupport应为布尔值;第三个$isSupport参数未使用;第四个原始问题:D
query($where:SomeWhereInputType){source{people(where:$where){
和变量:
{where:{isSupport:true}}