Skip to content

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

@FoundTheWOUT

Description

@FoundTheWOUT

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.topic: remark/mdxRelated to Markdown, remark & MDX ecosystemtype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions