Gatsby在graphql提取时生成的过程中给出错误“错误:名称为“文件”的类型不存在”

时间:2019-05-25 11:18:07

标签: graphql gatsby

试图建立一个盖茨比网站,但我很难调试与graphql模式有关的错误(我认为)。 我得到的错误是:

success open and validate gatsby-configs — 0.004 s
success load plugins — 0.276 s
success onPreInit — 0.004 s
success delete html and css files from previous builds — 0.018 s
success initialize cache — 0.008 s
success copy gatsby files — 0.009 s
success onPreBootstrap — 0.005 s
Starting to fetch data from Prismic
Fetch Prismic data: 919.580ms
success source and transform nodes — 0.975 s
error Type with name "File" does not exists


  Error: Type with name "File" does not exists

  - TypeStorage.js:44 SchemaComposer.get
    [operaloki]/[graphql-compose]/lib/TypeStorage.js:44:13

  - TypeMapper.js:86 TypeMapper.get
    [operaloki]/[graphql-compose]/lib/TypeMapper.js:86:44

  - TypeMapper.js:608 TypeMapper.typeFromAST
    [operaloki]/[graphql-compose]/lib/TypeMapper.js:608:17

  - TypeMapper.js:105 TypeMapper.getWrapped
    [operaloki]/[graphql-compose]/lib/TypeMapper.js:105:17

  - TypeMapper.js:272 TypeMapper.convertOutputFieldConfig
    [operaloki]/[graphql-compose]/lib/TypeMapper.js:272:114

  - configAsThunk.js:19 resolveOutputConfigAsThunk
    [operaloki]/[graphql-compose]/lib/utils/configAsThunk.js:19:41

  - configAsThunk.js:37 Object.keys.forEach.name
    [operaloki]/[graphql-compose]/lib/utils/configAsThunk.js:37:22

  - Array.forEach

  - configAsThunk.js:36 resolveOutputConfigMapAsThunk
    [operaloki]/[graphql-compose]/lib/utils/configAsThunk.js:36:27

  - ObjectTypeComposer.js:147 GraphQLObjectType.gqType._fields
    [operaloki]/[graphql-compose]/lib/ObjectTypeComposer.js:147:114

  - Array.reduce

  - SchemaComposer.js:130 SchemaComposer.buildSchema
    [operaloki]/[graphql-compose]/lib/SchemaComposer.js:130:12

  - schema.js:500 
    [operaloki]/[gatsby]/dist/schema/schema.js:500:47

我不知道这种File是什么类型,并且在我的文件中找不到该单词的任何出现。

有人知道吗?

2 个答案:

答案 0 :(得分:1)

gatsby-source-prismic-graphql插件的最新更新中,所有者推动了gatsby-image的支持。 从那时起,他更新了您应该开始使用的示例,但对于现有项目,您将需要添加以下三个插件以确保一切正常:

  • gatsby-source-filesystem
  • gatsby-transformer-sharp
  • gatsby-plugin-sharp

希望有帮助。

答案 1 :(得分:0)

我遇到了同样的问题,并添加了gatsby-source-filesystem,这有所帮助。 但是,对我而言,不清楚为什么Prismic突然开始需要它。早先使用相同的型号,则不需要。