datocms / gatsby-source-datocms

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

Gatsby Preview is not generating manifests and breaks #204

Closed joernroeder closed 1 year ago

joernroeder commented 1 year ago

Hi, I continue to dig into the reasons why our gatsby instance is slower than it needs to be — this issue focuses on the preview experience for our editors, see #202 and my comment at #201 for the others.

The issue I'm facing is that even tho I have the gatsby cloud plugin installed in the dato instance editors don't get fast previews right now even if I see previews being initiated by the content sync api with urls looking like the following:

https://www.gatsbyjs.com/content-sync/my-uuid/gatsby-source-datocms/63190429-2022-11-26T11:15:55.782+00:00/item_type-63190429

In the example linked here I'd expect a manifest with the id 63190429-2022-11-26T11:15:55.782+00:00 being created but that's not the case — it seems manifest files are not created at all.

After some digging I found this line

https://github.com/datocms/gatsby-source-datocms/blob/690fe239b6c03820d7469ed51144f87acb93b5c8/src/utils.js#L76

which seems to test if node.locale is set and uses the existence of a locale as a condition to determine whether a manifest is being created or not. To my knowledge their is no .locale key present on the node, also the docs don't mention anything related. I can filter by locale, but there seems no way to receive the locale of an entry via the graphql API — hence no manifests are being created, gatsby CMS preview builds successfully but leaves editors alone in the dark with a "Oh no! We've run into an error previewing your site." message.

My Dato Model GatsbyPage is straight forward: A title, slug, a content field and the gatsby cloud preview field.

Screenshot 2022-11-26 at 21 03 49

In Gatsby I use the fs routing.

// src/pages/{DatoCmsGatsbyPage.slug}.js

import React from "react"
import { graphql } from "gatsby"

export default function GatsbyPage(props) {
  return (
    <pre>
      {JSON.stringify(props, null, 2)}
    </pre>
  )
}

export const query = graphql`
  query($id: String!) {
    datoCmsGatsbyPage(id: { eq: $id }) {
      title
      content
    }
  }
`

Might be related to missing locale which I am seeing too: https://community.datocms.com/t/gatsby-cloud-log-flooded-with-verbose-logs-from-source-plugin/3503/1

stefanoverna commented 1 year ago

v5.0.3 should fix the issue (hopefully!)

joernroeder commented 1 year ago

YES! Thanks!