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

[gatsby-plugin-mdx 4.1.1] Example of extending the GraphQL "headings" nodes would't work. #36591

Closed
2 tasks done
FoundTheWOUT opened this issue Sep 11, 2022 · 1 comment · Fixed by #36593
Closed
2 tasks done
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: remark/mdx Related to Markdown, remark & MDX ecosystem type: bug An issue or pull request relating to a bug in Gatsby

Comments

@FoundTheWOUT
Copy link

FoundTheWOUT commented Sep 11, 2022

Preliminary Checks

Description

The example of creating "headings" GraphQL node seem like missing some thing when calling the compileMDXWithCustomOptions.
The resolver yield "TypeError: Cannot read properties of undefined (reading 'getState')".
And i found the secend parameters of the compileMDXWithCustomOptions, which is a object owning "store" attribute. This object would be passed down to enhanceMdxOptions, which would call the getState from the store.

store: NodePluginArgs["store"]

const { config } = helpers.store.getState()

Therefore, at the example, the object is missing the "store" attribute, undefined has no getState, and that causing the error.
But i have no idea what is the "store" meaning for, and what to pass in.

Reproduction Link

https://codesandbox.io/s/damp-sea-e242s4?file=/gatsby-node.js

Steps to Reproduce

Just follow the gatsby-plugin-mdx doc.

Expected Result

GraphQL resolve the heading properly.

Actual Result

GraphlQL yield "TypeError: Cannot read properties of undefined (reading 'getState')"

Environment

System: win11
Gatsby:4.22.1
gatsby-plugin-mdx:4.1.1

Config Flags

No response

@FoundTheWOUT FoundTheWOUT added the type: bug An issue or pull request relating to a bug in Gatsby label Sep 11, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 11, 2022
@LekoArts LekoArts added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: remark/mdx Related to Markdown, remark & MDX ecosystem and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Sep 12, 2022
@LekoArts
Copy link
Contributor

Thanks! Between writing the README and publishing the new version the store arg was added and the example wasn't updated. store refers to the internal Redux store that Gatsby uses.

You can check #36593 to see what you'll need to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: remark/mdx Related to Markdown, remark & MDX ecosystem type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants