cometkim / gatsby-plugin-typegen

Let's give developers using GatsbyJS better DX with extreme type-safety
https://www.gatsbyjs.org/packages/gatsby-plugin-typegen/
MIT License
204 stars 23 forks source link

Don't print errors in MDX files #117

Closed hasparus closed 2 years ago

hasparus commented 4 years ago

Howdy 👋

I just encountered this fellow

[typegen] Fail to extract GraphQL documents from /home/hasparus/workspace/homepage/src/pages/music.mdx Provided file type must be one of .js, .jsx, .ts, .tsx, .flow, .flow.js, .flow.jsx, .vue

TypeError: Provided file type must be one of .js, .jsx, .ts, . tsx, .flow, .flow.js, .flow.jsx, .vue

We couldn't use a generated type in .mdx file regardless, so this error seems redundant.

Is there a way to specify file extensions in plugin options, so the error doesn't happen?

cometkim commented 4 years ago

Hmm, I'm confusing. this plugin is notified by Gatsby what files have actually proceeded.

@hasparus Do you have GraphQL document snippets in the mdx file? Could you share your project config or provide a minimal repro?

hasparus commented 4 years ago

yup, I have a pageQuery in MDX file


some **markdown**

<Component site={page.data.sitePage} />

export const pageQuery = graphql`
  query MusicPageQuery($path: String!) {
    sitePage(path: {eq: $path}) {
      ...TweetDiscussEditLinksDataOnSitePage
    }
  }
`

I'm not sure if my config will be helpful, but I have it public on GitHub right here. I'm using gatsby-plugin-mdx with an MDX page inside of /pages.

cometkim commented 2 years ago

This should be fixed in v3 (gatsby-plugin-typegen@3.0.0-rc.0)