Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after installing gh-pages to the project: TypeError: data is undefined #5232

Closed
nileshgulia1 opened this issue May 2, 2018 · 2 comments

Comments

@nileshgulia1
Copy link

First of all Thanks to Gatsby, it's really great.
I just wrote personal blog out of Gatsby, it works fine but after installing gh-pages to deploy my blog to production, the command gatsby develop throws error:

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Invariant Violation: GraphQLParser: Unknown field `allMarkdownRemark` on type `RootQueryType`.Source: document `IndexQuery` file: `GraphQL request`.

This is my src/pages/index.js file:

export default function Index({ data }) {
  const { edges: posts } = data.allMarkdownRemark;
  return (
    <div className="blog-posts">
      {posts
        .filter(post => post.node.frontmatter.title.length > 0)
        .map(({ node: post }) => {
          return (
            <div className="blog-post-preview" key={post.id}>
              <h1>
                <Link to={post.frontmatter.path}>{post.frontmatter.title}</Link>
              </h1>
              <h2>{post.frontmatter.date}</h2>
              <p>{post.excerpt}</p>
            </div>
          );
        })}
    </div>
  );
}

export const pageQuery = graphql`
  query IndexQuery {
    allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) {
      edges {
        node {
          excerpt(pruneLength: 250)
          id
          frontmatter {
            title
            date(formatString: "MMMM DD, YYYY")
            path
          }
        }
      }
    }
  }
`;
@nileshgulia1
Copy link
Author

nileshgulia1 commented May 2, 2018

Also I have gatsby-transformer-remark enabled and .md named posts files as mentioned in #2150 and #2212 (knowing that graphQL will not query markdownremarkempty nodes) . Do I need to install gatsby-plugin-sharp package?

@nileshgulia1
Copy link
Author

nileshgulia1 commented May 3, 2018

Fixed with deleting node_modules folder and re-installing with npm. I guess problem was with yarn packages versioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant