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

fix(gatsby-plugin-mdx): fix filter by heading depth #16344

Merged
merged 1 commit into from
Aug 6, 2019
Merged

fix(gatsby-plugin-mdx): fix filter by heading depth #16344

merged 1 commit into from
Aug 6, 2019

Conversation

trevorblades
Copy link
Contributor

This branch fixes an issue where heading fields on an MDX node can't be filtered by depth. Here's the query that I was using:

{
  allMdx {
    nodes {
      headings(depth: h2) {
        depth
      }
    }
  }
}

In this case, all headings would be returned, regardless of their depth. This was happening because in the headings resolver, the depth arg was defined as a HeadingMdx here, but filtering would only happen if depth is a number.

I changed the logic to only perform filtering when depth is one of the values that HeadingMdx allows, and adjusted the filtering to make this strategy work properly.

@trevorblades trevorblades requested a review from a team as a code owner August 2, 2019 20:58
@ChristopherBiscardi
Copy link
Contributor

😅 thanks for catching this :)

@trevorblades
Copy link
Contributor Author

trevorblades commented Aug 3, 2019

@ChristopherBiscardi the www build failed, but do you think we can merge this in and publish a new version anyway?

hwillson added a commit to apollographql/apollo-client that referenced this pull request Aug 4, 2019
This is a workaround until gatsbyjs/gatsby#16344
is ready.
@ChristopherBiscardi
Copy link
Contributor

@trevorblades unfortunately merging is tied to WWW passing now. @gatsbyjs/core any idea what the github token issue is here?

@DSchau DSchau merged commit 234863c into gatsbyjs:master Aug 6, 2019
@DSchau
Copy link
Contributor

DSchau commented Aug 6, 2019

Published in gatsby-plugin-mdx@1.0.23

Thanks @trevorblades!

@trevorblades trevorblades deleted the trevorblades/gatsby-mdx-headings-filter branch August 6, 2019 18:38
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

Successfully merging this pull request may close these issues.

None yet

4 participants