GraphQLError:无法查询字段" category"在类型" ProductMarkdown"

时间:2018-03-21 13:38:32

标签: reactjs graphql gatsby

我正在使用gatsby,昨天一切正常,我今天继续尝试启动我的服务器并在控制台中出现大错误。我不能完全确定在哪里看,就像我昨天说的那样,它确实工作得很好。

⠁ [ { GraphQLError: Cannot query field "category" on type "ProductMarkdown".
    at Object.Field (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:65:31)
    at Object.enter (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/language/visitor.js:295:29)
    at Object.enter (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/language/visitor.js:337:25)
    at visit (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/language/visitor.js:227:26)
    at visitUsingRules (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/validation/validate.js:75:22)
    at validate (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/validation/validate.js:60:10)
    at /Users/taustin/Escalade/canopy-weights/node_modules/graphql/graphql.js:69:51
    at Promise._execute (/Users/taustin/.nvm/versions/node/v8.10.0/lib/node_modules/gatsby-cli/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/Users/taustin/.nvm/versions/node/v8.10.0/lib/node_modules/gatsby-cli/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/Users/taustin/.nvm/versions/node/v8.10.0/lib/node_modules/gatsby-cli/node_modules/bluebird/js/release/promise.js:79:10)
    at graphqlImpl (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/graphql.js:59:10)
    at graphql (/Users/taustin/Escalade/canopy-weights/node_modules/graphql/graphql.js:48:227)
    at graphqlRunner (/Users/taustin/Escalade/canopy-weights/node_modules/gatsby/dist/bootstrap/index.js:368:22)
    at _callee$ (/Users/taustin/Escalade/canopy-weights/node_modules/gatsby-plugin-product-markdown-pages/gatsby-node.js:32:14)
    at tryCatch (/Users/taustin/Escalade/canopy-weights/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/taustin/Escalade/canopy-weights/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/taustin/Escalade/canopy-weights/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/taustin/Escalade/canopy-weights/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/taustin/Escalade/canopy-weights/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (/Users/taustin/Escalade/canopy-weights/node_modules/core-js/library/modules/es6.promise.js:164:7)
    at Object.<anonymous> (/Users/taustin/Escalade/canopy-weights/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.createPages (/Users/taustin/Escalade/canopy-weights/node_modules/gatsby-plugin-product-markdown-pages/gatsby-node.js:95:15)
    message: 'Cannot query field "category" on type "ProductMarkdown".',
    locations: [ [Object] ],
    path: undefined } ]

我收到上述错误,通过查看我的所有文件,我只有一个地方叫productMarkdown。令我困惑的是,没有任何类别可供查找。我不确定发生了什么。运行gatsby develop时会发生此错误。

以下是查询:

productMarkdown(productId: { eq: $upperId }) {
      body
      title
      id
      titleDesc
      productInfo
      price
      active
      mainId
      cartParams {
        title
        options
      }
      extra {
        id
        title
      }
      specs {
        amount
        dimensions
      }
    }

1 个答案:

答案 0 :(得分:0)

我遇到了完全相同的问题,找不到任何错误并仔细检查了内容并使用了以下查询:http://localhost:8000/___graphql

我通过再次安装gatsby yarn add gatsby来修复它,它更新了以下软件包:

成功保存了6个新的依赖项。

├─gatsby-cli@2.4.1 ├─gatsby-link@2.0.2 ├─gatsby-plugin-page-creator@2.0.0 ├─gatsby-react-router-scroll@2.0.0 ├─gatsby@2.0.9 └─graphql-skip-limit@2.0.0

运行gatsby develop,现在可以使用与以前完全相同的代码/查询再次将字段拉细。给一个新的npm / yarn安装一下,看看是否有帮助。