datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

childMarkdownRemark failing on node.entityPayload.attributes #129

Closed tobinharris closed 3 years ago

tobinharris commented 3 years ago

Hi

I've been using DatoCMS for almost a year and recently updated my dependencies, and suddenly some queries aren't working. For example:

contentNode{
    childMarkdownRemark {          
      html
      timeToRead          
    }
  } 

The html is the problem (if I use id it's fine). Inspecting the error on the /__graphql I can see that the problem is this:

"TypeError: Cannot read property 'attributes' of undefined",  at resolve (/blah blah/node_modules/gatsby-source-datocms/hooks/sourceNodes/createTypes/utils/buildFluidFields.js:29:38)"

Any idea what's causing this. Here's my dependencies:

"datocms-client": "^3.1.1",
"dotenv": "^8.1.0",
"remark": "^12.0.1",
"gatsby": "^2.24.73",
"gatsby-background-image": "^0.9.12",
"gatsby-image": "^2.4.21",
"gatsby-plugin-advanced-sitemap": "^1.4.5",
"gatsby-plugin-google-analytics": "^2.1.34",
"gatsby-plugin-google-tagmanager": "^2.1.24",
"gatsby-plugin-hotjar": "^1.0.1",
"gatsby-plugin-netlify": "^2.3.17",
"gatsby-plugin-react-helmet": "^3.1.10",
"gatsby-plugin-robots-txt": "^1.5.0",
"gatsby-plugin-sass": "^2.1.17",
"gatsby-plugin-sharp": "^2.6.40",    
"gatsby-remark-images": "^3.3.33",
"gatsby-remark-images-datocms": "^0.0.9",
"gatsby-remark-images-medium-zoom": "^1.4.0",
"gatsby-source-datocms": "^2.4.1",
"gatsby-source-filesystem": "^2.1.29",
"gatsby-source-instagram": "^0.8",
"gatsby-transformer-remark": "^2.8.38",
"gatsby-transformer-sharp": "^2.5.17",

Any help appreciated!

stefanoverna commented 3 years ago

@tobinharris I don't think the error is related to the childMarkdownRemark, as it references gatsby-image related stuff. Would you mind sharing what your DatoCMS project (project ID or domain are fine) and the complete query that's failing?

You can also send these info from here if you don't want to publicly share them! https://www.datocms.com/support?topics=technical-support/ive-found-a-bug

tobinharris commented 3 years ago

Thanks @stefanoverna

It's all public info anyway so no problems.

export const query = graphql`
  query CaseStudyQuery($slug: String!) {
    caseStudy: datoCmsCasestudy(slug: { eq: $slug }) {
      seoMetaTags {
        ...GatsbyDatoCmsSeoMetaTags
      }
      title      
      slug     

      contentNode{
        childMarkdownRemark {          
          html
          timeToRead          
        }
      }  
      heroBannerImage {
        url
        fluid(maxWidth: 1024, imgixParams: {fm: "jpg", auto: "compress" }) {
          ...GatsbyDatoCmsFluid_tracedSVG
        }
      }
      client{
          companyName
          logo {
            url
            fluid(maxWidth: 1024, imgixParams: {fm: "png", auto: "compress" }) {
              ...GatsbyDatoCmsFluid_noBase64
            }
          }
          logoLight {
            url
            fluid(maxWidth: 150, imgixParams: {fm: "png", auto: "compress" }) {
              ...GatsbyDatoCmsFluid_noBase64
            }
            fixed(width: 150, imgixParams: {fm: "png", auto: "compress" }) {
                ...GatsbyDatoCmsFixed
              }
          }
      }      
    }
  }
`

Project ID is pocketworks-web

Thanks

Tobin

tobinharris commented 3 years ago

I think it's a DatoCMS field that's got a problem.

This works in the __graphql tool on localhost.

{
  datoCmsRadarBlip{
    bodyNode{
      childMarkdownRemark{
        html
      }
    }
  }
}

But this fails

datoCmsCasestudy {
    contentNode {
      childMarkdownRemark {
        html
      }
    }
  }

It turns out it's down to an image in the markdown of the contentNode. I still haven't figured out why markdown with an image is failing, but that seems to be what's causing it. Any help appreciated.

tobinharris commented 3 years ago

If I take out gatsby-remark-images-datocms from my config it works. The images in the markdown of my collection no longer kill the site. Any plan to update this library?

stefanoverna commented 3 years ago

Just released gatsby-remark-images-datocms@0.1.0 which solves this issue!