首页 文章

Gatsby源API服务器转换属性名称,不允许GraphQL查询

提问于
浏览
0

Gatsby Source API服务器运行良好 . 有了这个在我的gatsby-config:

{
        resolve: 'gatsby-source-apiserver',
        options: {
            typePrefix: 'community_education__',
            url: `https://spreadsheets.google.com/feeds/list/1DLAVN3q758sPohCFeZlVSVRZKXzEser1SIsQnH2mvrw/ogwtdyp/public/basic?hl=en_US&alt=json`,
            method: 'get',
            name: `classes`,
            entityLevel: `feed.entry`,
            schemaType: classType,
            localSave: true,
            path: `${__dirname}/api/`,
            verboseOutput: true,
        }
    }

它正确地下拉了我想要的数据 . 问题是我使用的API(谷歌)带来了以下属性:

{
    "title": {
      "type": "text",
      "$t": "Computer Coding for Kids"
    },
    "content": {
      "type": "text",
      "$t": "district: Hopkins, days: Mon - Thurs, startdate: 6/11/2018, enddate: 6/14/2018, time: 9am - Noon, grades: 3rd, 4th, 5th, 6th Grades, description: Learn how to code through playing games and having fun! We'll learn the fundamentals of loops, if statements, and variables as we learn the blockly and python computer languages!  Please come with internet navigation skills (basic typing and mouse control) and a passion to work hard and have fun!, link: https://hopkins.ce.eleyo.com/course/6064/youth-summer-2018/computer-coding-for-kids"
    }
  }

当我进行GraphQL查询时,可用的属性是 typealternative__t 这实际上是可以的,除了 alternative__t 总是返回 null .

这个查询:

{
  allCommunityEducationClasses {
    totalCount
    edges {
      node {
        title {
          type
          alternative__t
        }
        content {
          type
          alternative__t
        }
      }
    }
  }
}

返回此结果:

{
      "node": {
        "title": {
          "type": "text",
          "alternative__t": null
        },
        "content": {
          "type": "text",
          "alternative__t": null
        }
      }
    },
    {
      "node": {
        "title": {
          "type": "text",
          "alternative__t": null
        },
        "content": {
          "type": "text",
          "alternative__t": null
        }
      }
    },

我知道问题是 $t ,如果它是我自己的API,我可以更改响应名称属性,我会,但这是谷歌API . 我可以以某种方式重命名该属性吗?有没有办法使用转义字符来查询 $t

1 回答

相关问题