Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Cannot query field "childMdx" on type "File" #93

Closed
heitorlessa opened this issue Jan 29, 2020 · 11 comments
Closed

Cannot query field "childMdx" on type "File" #93

heitorlessa opened this issue Jan 29, 2020 · 11 comments

Comments

@heitorlessa
Copy link

Hello,

It's my first time trying gatsby because of this wonderful theme, however I couldn't get it work due to this error:

Cannot query field "childMdx" on type "File".

Let me know if there's any file/content you want me to share - I'm mostly trying to get a hello-world working at this stage.

Thank you

@trevorblades
Copy link
Contributor

trevorblades commented Feb 6, 2020

Hey @heitorlessa, thanks for trying the theme out. I recently merged #96 which attempts to make it easier to understand how to get the theme up and running. One of the things I did was add a "required" column to the options table and try to reduce the number of required options to the bare minimum.

Regarding your issue, at the moment the theme has logic in it that expects both Markdown and MDX to exist. One of the things that I was hoping to do in this PR was remove this constraint, but it proved to be too difficult and I'm going to come back to it later.

For now, I'd recommend you just create a dummy MDX file with title and description frontmatter so that Gatsby can create the types and fields it needs to in it's GraphQL schema. I put together an example of a smallest-possible-config implementation of the theme for your reference. Notice I've got an index.md and a dummy.mdx file in the content directory (the default value for the contentDir option).

@heitorlessa
Copy link
Author

That's awesome to hear -- I will try them tomorrow and ping back here

@heitorlessa
Copy link
Author

heitorlessa commented Feb 6, 2020

Just tested and that worked beautifully! Had some issues with siteMetadata but copied from my previous config.

The only piece I couldn't figure out from the docs is - How do I remove Discuss on Spectrum/Edit on GitHub/Launch Graph Manager as I don't use it?

Thanks again

@trevorblades
Copy link
Contributor

If you're using the latest version of the theme (4.0.3 at this time), you should see no GitHub or Spectrum links as long as you don't pass githubRepo or spectrumHandle options to the theme when you configure it.

To remove the "Launch Graph Manager" button, simply shadow the header-button.js file with a function that returns null.

// src/gatsby-theme-apollo-docs/components/header-button.js
export default () => null;

I've updated the example with the latest version of the Gatsby theme and implemented the HeaderButton shadowing technique that I mentioned!

@heitorlessa
Copy link
Author

heitorlessa commented Feb 6, 2020 via email

@heitorlessa
Copy link
Author

One small correction - Edit on GitHub still appears even when githubRepo key isn't present; same behaviour with your Sandbox example.

@trevorblades
Copy link
Contributor

@heitorlessa I'm not seeing the "Edit on GitHub" link in the codesandbox anymore: https://bywp2.sse.codesandbox.io/

This was an issue at one point after publishing v4 of the theme, but I fixed it in version 4.0.2 with this commit. Try upgrading your theme version with npm install gatsby-theme-apollo-docs@latest to get the fix! 👍

@heitorlessa
Copy link
Author

heitorlessa commented Feb 13, 2020 via email

@yonatanLehman
Copy link

Hi
I had the same problem, and tried building the exmample you give.
I did the following

  1. added content/components/dummy.mdx
  2. added content/dummy.mdx
  3. added conten t.index.md
  4. add gatsby-theme-apollo-docs/components\heaader-button.js
  5. copied gatsby-config.js as is
    This failed with error #85923
    Cannot query field "description" on type "MdxFrontmatter".

Did I miss something out?
Thanks

@yonatanLehman
Copy link

THe version I'm using is
"dependencies": {
"gatsby": "^2.29.3",
"gatsby-theme-apollo-docs": "^4.5.12",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}

@trevorblades
Copy link
Contributor

trevorblades commented Dec 31, 2020

@yonatanLehman make sure you add title and description frontmatter in both of your mdx and md files! Let me know if that works.

---
title: test title
description: this is a description
---

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

No branches or pull requests

3 participants