Migrate to V4 - Need help - Errors

My config file:

`

  resolve: "gatsby-source-prismic",
  options: {
    repositoryName: "xx",
    accessToken:
      "xx",


    linkResolver: (doc) => `/${doc.id}`,
    htmlSerializer: (type, element, content, children) => {
      // Your HTML Serializer
    },

  
    schemas: {
      // Your custom types mapped to schemas
      navigation: require("./src/schemas/navigation.json"),
      productpage: {
        productpage: require("./src/schemas/productpage.json"),
      },
    },

 
    lang: "*",

    // Set a function to determine if images are downloaded locally and made
    // available for gatsby-transformer-sharp for use with gatsby-image.
    // The document node, field key (i.e. API ID), and field value are
    // provided to the function, as seen below. This allows you to use
    // different logic for each field if necessary.
    // This defaults to always return false.
    shouldDownloadImage: ({ node, key, value }) => {
      // Return true to download the image or false to skip.
    },

    // Provide a default set of Imgix image transformations applied to
    // Imgix-backed gatsby-image fields. These options will override the
    // defaults set by Prismic.
    // See: https://docs.imgix.com/apis/url
    imageImgixParams: {
      auto: "compress,format",
      fit: "max",
      q: 50,
    },

    // Provide a default set of Imgix image transformations applied to
    // the placeholder images of Imgix-backed gatsby-image fields. These
    // parameters will be applied over those provided in the above
    // `imageImgixParams` option.
    // See: https://docs.imgix.com/apis/url
    imagePlaceholderImgixParams: {
      w: 100,
      blur: 15,
      q: 50,
    },
  },
},

`

I am getting errors when running gatsby develop after migrating to V4.

The error I get is: Missing onError handler for invocation 'building-schema', error was 'Error: Type with name "PrismicAllDocumentTypes" does not exists'. Stacktrace was 'Error: Type with name "PrismicAllDocumentTypes" does not exists

The error I get is when I remove shouldDownloadImage: is also a scheme error but something about GatsbyImageLayout.

Anyone here who can help?

Hey @dfmkraaijeveld thanks for reaching out

I believe there's a problem with how you declared the schemas. Also, you could try and set up the Link Resolver in a separate file and then import it to the configuration. The link resolver needs to check the type of document in the page to be able to create the pages.

    {
      resolve: 'gatsby-source-prismic',
      options: {
        repositoryName: 'xx',
        accessToken: 'xx',
        linkResolver: require('./src/utils/linkResolver').linkResolver,
        htmlSerializer: (type, element, content, children) => {
          // Your HTML Serializer
        },

        schemas: {
          // Your custom types mapped to schemas
          navigation: require('./src/schemas/navigation.json'),
          productpage: require('./src/schemas/productpage.json'),
        },
        // all other plugin options
      },
    },

Hi, Dennis! I had the same issue. I fixed it by providing empty objects schemas for every old custom type, even for deleted ones. We need provide normal schema for actual custom types and empty objects for old custom types, which are not in use any more.

Tried it, but did not work in my case.. I reached out to the lead dev and it turns out its related to gatsby-source-shopify and gatsby-source-prismic both implementing GatsbyImageData

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.