danielmahon/gatsby-remark-relative-images

Field "bannerImage" must not have a selection since type "String" has no subfields.

jamessimone opened this issue · 2 comments

I would love to upgrade, however when upgrading to 2.0.2 (from 0.2.3), I am getting the titled error with no changes other than having removed fmImagesToRelative as recommended in my gatsby-node.js. I am using NetlifyCMS in conjunction with Gatsby, like you, so I'm curious where the breakdown is occurring.

My config.yml values align exactly with yours. Here's the relevant excerpt from my gatsby-config.js file (some plugins omitted for brevity):

{
//...
  "plugins" : {
//...
        resolve: "gatsby-source-filesystem",
      options: {
        path: `${__dirname}/static/img`,
        name: "uploads",
      },
    },
    {
      resolve: "gatsby-source-filesystem",
      options: {
        path: `${__dirname}/src/pages`,
        name: "pages",
      },
    },
    {
      resolve: "gatsby-source-filesystem",
      options: {
        path: `${__dirname}/src/img`,
        name: "images",
      },
    },
    {
      resolve: "gatsby-source-filesystem",
      options: {
        path: `${__dirname}/src/content`,
        name: "content",
      },
    },
    {
      resolve: "gatsby-transformer-remark",
      options: {
        plugins: [
          "gatsby-remark-relative-images",
          {
            resolve: "gatsby-remark-images",
            options: {
              maxWidth: 800,
              linkImagesToOriginal: false,
              quality: 90,
              showCaption: true,
            },
          },
// etc ...
  }
}

Pretty standard stuff. The only difference I can see is in my markdown frontmatter:

---
bannerImage: /img/sheila-anne-writing-desk.jpg
# etc ...
---

Whereas it seems (in your readme example at least) that you have the paths contained within an object. When querying the updated fields (the GraphQL server starts up even though the bundle for the site fails to be created, thankfully), I can see that they are still strings, but with some updates: ..\..\..\static\img\sheila-anne-writing-desk.jpg

This is an open source repo, hopefully that helps.

In short - thanks for your hard work on this plugin. Hopefully we can get to the bottom of the issue!

@jamessimone reproducing your repo I ran across a few missing or misnamed files (ie: jpg versus jpeg). v2 throws an error now when It doesn't find a matching file for fields it tries to convert since this will break the gatsby-remark-image processing. After fixing the missing files, I no longer got the error and the build worked fine. You also need to make sure fields you define in frontmatter exist in every other markdown file of the same type. Conditional image fields may require you to override the type as Gatsby's automatic type inference fails: https://www.gatsbyjs.com/docs/schema-customization/#automatic-type-inference

Let me know if you continue to have issues

@danielmahon thanks so much for the response. I can take it from here!