首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gatsby: gatsby源-graphql:无法读取未定义的属性“createPageDependency”

Gatsby: gatsby源-graphql:无法读取未定义的属性“createPageDependency”
EN

Stack Overflow用户
提问于 2019-12-12 06:49:21
回答 1查看 674关注 0票数 0

我正在为fireblog ( https://fireblogcms.com/ )构建一个Gatsby主题,它有一个GraphQL API。因此,我尝试了gatsby-source-graphql插件,这似乎是可行的方法:

当按照本页的说明:https://www.gatsbyjs.org/packages/gatsby-source-graphql/然后访问http://localhost:8000/___graphql时,我在对新类型运行GraphQL查询时遇到了这个问题Cannot read property 'createPageDependency' of undefined

复制:

将此配置

  • yarn add gatsby-source-graphql
  • add到gatsby-config.js

代码语言:javascript
复制
  plugins: [
    // Simple config, passing URL
    {
      resolve: "gatsby-source-graphql",
      options: {
        // This type will contain remote schema Query type
        typeName: "fireblog",
        // This is field under which it's accessible
        fieldName: "fireblog",
        // Url to query from
        url: "https://api.fireblogcms.com/graphql/blog/5de7a2934360f60004130881"
      }
    },
  //...
  ], 

转到http://localhost:8000/___graphql

并运行查询:

代码语言:javascript
复制
{
  fireblog {
    posts(last: 20) {
      edges {
        node {
          title
        }
      }
    }
  }
}

预期结果

我期望查询在没有错误的情况下运行,或者提供一条错误消息来解释下一步我应该做什么来使这个查询工作。

实际效果

发生了什么:

代码语言:javascript
复制
{
  "errors": [
    {
      "message": "Cannot read property 'createPageDependency' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "fireblog"
      ]
    }
  ],
  "data": null
}

gatsby info --clipboard

代码语言:javascript
复制
  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.12.0 - ~/.nvm/versions/node/v10.12.0/bin/node
    Yarn: 1.17.3 - ~/.yarn/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.12.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 78.0.3904.108
    Firefox: 69.0.3
    Safari: 13.0.3
  npmPackages:
    gatsby: ^2.1.10 => 2.1.10
    gatsby-image: ^2.0.29 => 2.0.29
    gatsby-plugin-feed: ^2.0.13 => 2.0.13
    gatsby-plugin-google-analytics: ^2.0.14 => 2.0.14
    gatsby-plugin-html2amp: ^0.4.0 => 0.4.0
    gatsby-plugin-manifest: ^2.0.18 => 2.0.18
    gatsby-plugin-offline: ^2.0.24 => 2.0.24
    gatsby-plugin-react-helmet: ^3.0.6 => 3.0.6
    gatsby-plugin-sharp: ^2.0.21 => 2.0.21
    gatsby-plugin-typography: ^2.2.7 => 2.2.7
    gatsby-remark-copy-linked-files: ^2.0.9 => 2.0.9
    gatsby-remark-images: ^2.0.6 => 2.0.6
    gatsby-remark-prismjs: ^3.2.4 => 3.2.4
    gatsby-remark-responsive-iframe: ^2.0.9 => 2.0.9
    gatsby-remark-smartypants: ^2.0.8 => 2.0.8
    gatsby-source-filesystem: ^2.0.20 => 2.0.20
    gatsby-source-graphql: ^2.1.28 => 2.1.28
    gatsby-transformer-remark: ^2.2.5 => 2.2.5
    gatsby-transformer-sharp: ^2.1.14 => 2.1.14
  npmGlobalPackages:
    gatsby-cli: 2.8.8
EN

回答 1

Stack Overflow用户

发布于 2019-12-12 07:41:50

问题似乎是我的节点版本,我在节点12.4.0上的最后一次测试没有问题。如果我记得清楚的话,我以前在节点10.13.0

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59299132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档