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

Cannot query field \"allMarkdownRemark\" on type \"RootQueryType\ #3150

Closed
thebetterjort opened this issue Dec 6, 2017 · 14 comments
Closed
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@thebetterjort
Copy link

thebetterjort commented Dec 6, 2017

  "message": "Cannot query field \"allMarkdownRemark\" on type \"RootQueryType\".",

query

{ allMarkdownRemark { edges { node { title } } }

package.json
{ "name": "gatsby-starter-hello-world", "description": "Gatsby hello world starter", "license": "MIT", "scripts": { "develop": "gatsby develop", "build": "gatsby build", "serve": "gatsby serve" }, "dependencies": { "gatsby": "^1.9.119", "gatsby-link": "^1.6.28", "gatsby-plugin-styled-components": "^2.0.3", "gatsby-plugin-typography": "^1.7.10", "gatsby-remark-copy-linked-files": "^1.5.22", "gatsby-source-filesystem": "^1.5.9", "gatsby-transformer-json": "^1.0.13", "gatsby-transformer-remark": "^1.7.23", "styled-components": "^2.2.4", "typography": "^0.16.6", "typography-theme-bootstrap": "^0.16.7", "typography-theme-lawton": "^0.15.10", "typography-theme-us-web-design-standards": "^0.16.9" } }

http://localhost:8000/___graphql?query=%7B%0A%20%20allMarkdownRemark%20%7B%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%09%09%09title%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D

I also cannot query JSON file or markdown files as I expect.

I have json file in /data/a.json with { 'value': 'a' }

I have rm -rf node_modules/ and reinstalled.
I have used two browsers just in case of cache issue.

gatsby-config.js

`

module.exports = {

siteMetadata: {
    title: `ARWD`,
  },
plugins: [
 `gatsby-transformer-json`,
 `gatsby-transformer-remark`,
 `gatsby-plugin-styled-components`,
 `gatsby-plugin-typography`, 

{
    resolve: `gatsby-plugin-typography`,
    options: {
      pathToConfigModule: `src/utils/typography.js`,
    }
},
{
    resolve: `gatsby-source-filesystem`,
    options: {
      name: `CMECF`,
      path: `${__dirname}/public/files/CMECF`,
    }
},
{
    resolve: `gatsby-source-filesystem`,
    options: {
      name: `Attorney`,
      path: `${__dirname}/public/files/Attorney`,
    }
},
{
    resolve: `gatsby-source-filesystem`,
    options: {
      name: `Applications`,
      path: `${__dirname}/public/files/Applications`,
    }
},
{
    resolve: `gatsby-source-filesystem`,
    options: {
      name: `Files`,
      path: `${__dirname}/public/files`,
    }
},
],

}

`

@kildareflare
Copy link

kildareflare commented Dec 10, 2017

Possibly related to #2212

@jonathan-chin
Copy link

jonathan-chin commented Dec 21, 2017

I'm getting the same error:

GraphQLError: Cannot query field "allMarkdownRemark" on type "RootQueryType"

the thing is I have two gatsby sites. they are forks of the same root project. One works fine and builds without a problem. the other throws that error. they are structured similarly.

I even cp'd the node_modules folder directly from working to non working project, in case it was a version problem.

@KyleAMathews
Copy link
Contributor

Does the site with the error have any markdown files?

@osteele
Copy link

osteele commented Dec 28, 2017

The error @jonathan-chin is seeing is probably #3103 in conjunction with #2212.

If the @thebetterjort's repo includes markdown files, it may also be consequent to #3103.

@thebetterjort
Copy link
Author

thebetterjort commented Mar 1, 2018

The repo does include markdown files. #3103 seems related. It's working after I recreated the config.

@m-allanson
Copy link
Contributor

@thebetterjort Is this now working for you with the latest version of Gatsby?

@m-allanson m-allanson added type: question or discussion Issue discussing or asking a question about Gatsby status: needs more info Needs triaging and reproducible examples or more information to be resolved and removed GraphQL labels Apr 13, 2018
@droidMakk
Copy link

droidMakk commented May 29, 2018

I'm still getting this error!

My package.json

{
  "name": "gatsby-starter-default",
  "description": "Gatsby default starter",
  "version": "1.0.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "gatsby": "^1.9.247",
    "gatsby-link": "^1.6.40",
    "gatsby-plugin-catch-links": "^1.0.22",
    "gatsby-plugin-react-helmet": "^2.0.11",
    "gatsby-source-filesystem": "^1.5.36",
    "gatsby-transformer-remark": "^1.7.41",
    "react-helmet": "^5.2.0",
    "react-media": "^1.8.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write 'src/**/*.js'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "prettier": "^1.12.0"
  }
}

My gatsby-config.js

module.exports = {
  siteMetadata: {
    title: 'Gatsby Default Starter',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-catch-links',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      }
    },
    'gatsby-transformer-remark'
  ],
}

I do have an md file

dirstr

Graphql query for blog-post.js

export const pageQuery = graphql (
  query BlogPostByPath($path: String!) {
    markdownRemark(frontmatter: { path: { eq: $path } }) {
      html
        frontmatter {
        date(formatString: "MMMM DD, YYYY")
        path
        title
      }
    }
  }
);

@pieh
Copy link
Contributor

pieh commented May 29, 2018

@droidMakk Can you share repository so we could reproduce the problem? There is not enough context in stuff you posted to figure out what's wrong

@droidMakk
Copy link

droidMakk commented May 29, 2018

@pieh
https://github.com/droidmakk/droidblog
For some reason the url is looking broken.
Though try searching for droidmakk/droidblog. That's where you'll find it!
Thanks, for the help.

@flipactual
Copy link
Contributor

Hey @droidMakk 👋

Using Node v9.6.1 I did a fresh clone of your repository, checked out the master branch, ran yarn, then ran yarn develop and saw no errors – things appear to have been working fine

More information on your environment and the commands you're running could be useful, but you might also try doing a fresh clone of the project like I did to see if that sorts things out

@droidMakk
Copy link

Hey @flipactual @pieh . Thanks for the help been migrating my work folders from one user to the other to test if the path was the problem. Turns out actually that was the problem.

Thanks again for the help guys!

@flipactual
Copy link
Contributor

Glad to hear it's working @droidMakk!

Per this conversation and #3150 (comment) I'm going to close the issue, but feel free to reopen or a create a new issue if the problem pops back up again

@necheporenko
Copy link

Using plugin gatsby-source-filesystem add also path to your folder with .md files.

@bingalls
Copy link

My code had been working, but a recent upgrade to around 2.18 seems to have broken the gatsby-tinacms-remark plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests