Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 - Error: Type with name "File" does not exists #97

Closed
gbreux opened this issue May 22, 2019 · 12 comments
Closed

v3 - Error: Type with name "File" does not exists #97

gbreux opened this issue May 22, 2019 · 12 comments
Labels
V3 Related to v3

Comments

@gbreux
Copy link

gbreux commented May 22, 2019

Hi,

I'm giving the alpha v3 a try (because I need optional field :)) but I encounter this error when I try to start :


  Error: Type with name "File" does not exists
  
  - TypeStorage.js:44 SchemaComposer.get
    [prismic]/[graphql-compose]/lib/TypeStorage.js:44:
    13
  
  - TypeMapper.js:86 TypeMapper.get
    [prismic]/[graphql-compose]/lib/TypeMapper.js:86:4
    4
  
  - TypeMapper.js:608 TypeMapper.typeFromAST
    [prismic]/[graphql-compose]/lib/TypeMapper.js:608:
    17
  
  - TypeMapper.js:105 TypeMapper.getWrapped
    [prismic]/[graphql-compose]/lib/TypeMapper.js:105:
    17
  
  - TypeMapper.js:272 TypeMapper.convertOutputFieldCon
    fig
    [prismic]/[graphql-compose]/lib/TypeMapper.js:272:
    114
  
  - configAsThunk.js:19 resolveOutputConfigAsThunk
    [prismic]/[graphql-compose]/lib/utils/configAsThun
    k.js:19:41
  
  - configAsThunk.js:37 Object.keys.forEach.name
    [prismic]/[graphql-compose]/lib/utils/configAsThun
    k.js:37:22
  
  - Array.forEach
  
  - configAsThunk.js:36 resolveOutputConfigMapAsThunk
    [prismic]/[graphql-compose]/lib/utils/configAsThun
    k.js:36:27
  
  - ObjectTypeComposer.js:147 GraphQLObjectType.gqType
    ._fields
    [prismic]/[graphql-compose]/lib/ObjectTypeComposer

Any idea where this can come from? How can I help you get more information about that?

PS: I copied the json files in their schema folder and added it to the config

@angeloashmore
Copy link
Member

@gbreux Thanks for giving it a try! We are planning to publish a beta soon but I'll see if there's a better solution to this before we publish.

The File type is used for the gatsby-image integration. The localFile field of any image field is of type File.

You can see it here: https://github.com/angeloashmore/gatsby-source-prismic/blob/v3-beta/src/standardTypes.graphql#L70

Do you have gatsby-plugin-sharp and gatsby-transformer-sharp installed in your project?

If you are able to clear you cache, could you also try gatsby clean before trying again?

@gbreux
Copy link
Author

gbreux commented May 23, 2019

I see, I reinstalled my node_modules, used gatsby clean and I don't have the gatsby plugin you mentioned, but I still have the error. Here is my dependencies:

"dependencies": {
    "gatsby": "^2.6.3",
    "query-string": "^6.5.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.1",
    "react-js-pagination": "^3.0.2",
    "react-typography": "^0.16.19",
    "styled-components": "^4.2.0",
    "typography": "^0.16.19"
  },
  "devDependencies": {
    "babel-plugin-styled-components": "^1.10.0",
    "dotenv": "^8.0.0",
    "gatsby-plugin-netlify": "^2.0.17",
    "gatsby-plugin-styled-components": "^3.0.7",
    "gatsby-plugin-typography": "^2.2.13",
    "gatsby-source-prismic": "^3.0.0-alpha.2",
    "prettier": "^1.17.0"
  }

🤔

@angeloashmore
Copy link
Member

@gbreux Any chance your repo is open source? Could we take a look?

If not, could you create a simple repo that reproduces the issue? @asyarb tried recreating the issue with different combinations of image fields and plugins but wasn't able to get the same thing you're experiencing.

@gbreux
Copy link
Author

gbreux commented May 24, 2019

Sure, here it is: https://github.com/gbreux/nodokasa

@gbreux
Copy link
Author

gbreux commented May 25, 2019

Interesting, I didn't have any image field on my schemas (I don't need one). But once I added one just for testing, I don't have this error anymore.

Edit confirmed: If you have just one article published with an image field no matter where, you don't get this error

@angeloashmore
Copy link
Member

@gbreux It's possible that we're telling Gatsby that images have a localFile field with type File, but Gatsby doesn't know what File is until one is created.

I don't have a solution in mind yet, but your diagnosis is helpful. Thank you!

@gbreux
Copy link
Author

gbreux commented May 25, 2019

Happy to help, in the meantime I can just create a temporary custom type with one element and a picture that I will never use.

Hope you'll find a solution :)

@jenshandersson
Copy link

I just ran into this same issue. Created a fresh repository with 1 page (without setting any image). After setting an image in my content this error went away.

@angeloashmore
Copy link
Member

This should be resolved upstream in gatsby-source-filesystem. 🎉

@ryanditjia
Copy link

Still getting the error even with gatsby-source-filesystem updated.

@good-idea
Copy link
Contributor

good-idea commented Sep 10, 2019

I'm getting this with the latest versions installed,

    "gatsby-source-filesystem": "^2.1.22",
    "gatsby-source-prismic": "^3.0.0-beta.10",

I had shouldNormalizeImage always return false, because I don't need the images locally. That was causing the error. My hacky fix was to include one image:

gatsby-config.js

let should = true

module.exports = {
  // ...
  plugins: [
   // ...
    {
      resolve: `gatsby-source-prismic`,
      options: {
        shouldNormalizeImage: (...args) => {
          const should = once
          once = false
          return should
        },
      },
    },
  ],
}

@angeloashmore do you work for Prismic? If not, they should be sponsoring you.

@martaver
Copy link

martaver commented Nov 30, 2019

Heya,

I'm on what I (think) is the latest release of this plugin 3.0.0-beta.15, but I'm still getting this issue.

I have a repro here: https://github.com/beaufort-asia/www/tree/repro

I'm getting it even though I published dummy articles with Image fields included and all that.

Maybe an edge case here that you missed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V3 Related to v3
Projects
None yet
Development

No branches or pull requests

6 participants