Javascript Gatsby查询类型未显示在graphiQl中

Javascript Gatsby查询类型未显示在graphiQl中,javascript,gatsby,Javascript,Gatsby,我正在创建一个盖茨比插件。在开发中,我没有收到任何错误或警告,但在graphiql(或at)中看不到我的查询 这是我在根目录中的插件文件夹结构 在文件夹中,index.js是一个空文件 getsby-node.js看起来像这样 const selfSdk = require('selfSdk') function createNodeContent (data, id, type) { const nodeId = createNodeId(id) const nodeConte

我正在创建一个盖茨比插件。在开发中,我没有收到任何错误或警告,但在graphiql(或at)中看不到我的查询

这是我在根目录中的插件文件夹结构

在文件夹中,
index.js
是一个空文件

getsby-node.js看起来像这样

 const selfSdk = require('selfSdk')

 function createNodeContent (data, id, type) {
  const nodeId = createNodeId(id)
  const nodeContent = JSON.stringify(data)
  const contentDigest = createContentDigest(data)
  const nodeMeta = {
    id: nodeId,
    parent: null,
    children: [],
    internal: {
      type: type, // used to generate the resulting GraphQL query name
      content: nodeContent,
      contentDigest
    }
  }
  const node = Object.assign({}, data, nodeMeta)
  return node
}

exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }, {
  workspaceId, 
  schemaId
}) => {
  const { createNode, setPluginStatus } = actions
  const workspace = selfSdk.getWorkspace(workspaceId)
  console.log(workspaceId, schemaId)
  // If there is schemaId but we don't have itemId, load all posts 
  try {
      const itemsList = await workspace.read(schemaId)
      const type = `getPosts`
      itemsList.forEach(({data, id}) => {
        createNode(createNodeContent(data, id, type))
      })


} catch (error) {
    console.error(`Error Fetching data`)
    console.error(error)
  }
  setPluginStatus({
    status: {
      lastFetched: Date.now()
    }
  }) 
}
这是我的grphiql


盖茨比将在插件文件夹的根目录中查找
Gatsby node.js

plugins/
– your-plugin/
-- gatsby-node.js
-- package.json


这就是为什么它没有出现在GraphiQL中。插件中没有要生成的节点,因为您有一个空白的
index.js
,因此它看起来像一个不导出任何内容的模块。

尝试调试
itemsList
的值。另外,
createNode()
返回一个承诺。@Z.Zlatev无法理解您的评论。对不起,您是否通过babel或类似的方式运行
src
?否则,gatsby-node.js必须位于根目录中,即index.js IIRC旁边
plugins/
– your-plugin/
-- gatsby-node.js
-- package.json