Add featuredImage in a Gatsby blog with MDX

I'm trying to add a featured image on my Gatsby blog but can't make it work. I tried several things found here and there but I just keep having this error message : Field "featuredImage" must not have a selection since type "String" has no subfields.

Here is my blog structure :

src
 |- images
   |- house.jpeg
 | - pages
   |- actualites
     |- house.mdx

My house.mdx has the following frontmatter :

---
title: House
path: /house
date: 2019-01-29
featuredImage: ../../images/house.jpeg
---

And my gatsby-plugin looks like this :

plugins: [
    `gatsby-plugin-resolve-src`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 800,
            },
          },
        ],
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        gatsbyRemarkPlugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 1200,
            },
          },
        ],
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
  ],

I can't figure out what I'm doing wrong... The http://localhost:8000/___graphql shows me my featuredImage but not the subfields for the image, so I guess it doesn't understand that my field is an image.

Could you please help me point what I am missing ?

Thank you 😊



Read more here: https://stackoverflow.com/questions/64400452/add-featuredimage-in-a-gatsby-blog-with-mdx

Content Attribution

This content was originally published by mdubus at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: