Skip to content

[gatsby-transformer-javascript-static-exports] Usage with gatsby-image #2929

@fabe

Description

Hi! I'm using gatsby-transformer-javascript-static-exports to pull in data from pages into my layout:

layouts/index.js:

export const pageQuery = graphql`
  query IndexQuery {
    site {
      siteMetadata {
        title
      }
    }
    allJsFrontmatter(
      filter: { data: { isWork: { eq: true } } }
      sort: { fields: [data___date], order: DESC }
    ) {
      edges {
        node {
          data {
            error
            title
            path
            cover {
              childImageSharp {
                sizes(maxWidth: 1400, quality: 95) {
                  ...GatsbyImageSharpSizes_withWebp
                }
              }
            }
          }
        }
      }
    }
  }
`;

pages/page.js:

export const data = {
  isWork: true,
  subtitle: 'Subtitle.',
  title: 'Title.',
  date: '2017-04-01',
  path: '/page',
  cover: './cover.png',
};

This worked in the past (and still works on production/netlify). However, now locally it gives me these errors on both gatsby develop and gatsby build:

The GraphQL query from /src/layouts/index.js failed

        Errors:
          GraphQLError: Path must be a string. Received undefined,GraphQLError: Path must be a string. Received undefined,GraphQLError: Path must be a string. Received undefined,GraphQLError: Path must be a string. Received undefined,GraphQLError: Path must be a string. Received undefined 

It seems to me that the layout somehow doesn't receive the correct path for the cover data item (which referencing an existing image in the same folder). This is possibly related to #1819, no answers there.

I'm on node 8.5.0 (also tested with 6.9.2), and gatsby-cli 1.1.20. Tried reinstalling and rebuilding everything, but no change.

Thanks!

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions