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

Output scheme to theme instead of starter #167

Open
kalebheitzman opened this issue Jun 21, 2021 · 2 comments
Open

Output scheme to theme instead of starter #167

kalebheitzman opened this issue Jun 21, 2021 · 2 comments
Labels
discussion enhancement New feature or request

Comments

@kalebheitzman
Copy link

Consider the following example:

{
  resolve: `gatsby-plugin-typegen`,
  options: {
    outputPath: `${__dirname}/src/__generated__/gatsby-types.d.ts`,
    emitSchema: {
      'src/__generated__/gatsby-introspection.json': true,
    },
    emitPluginDocuments: {
      'src/__generated__/gatsby-plugin-documents.graphql': true,
    },
  }
}

Shipping types with a theme by changing the output directory and this correctly puts the types in the theme that I'm developing. Is there an option to make the schema and plugin documents output inside of the theme instead of the main/starter project. I'm loading this plugin from the theme as well.

I'm using yarn workspaces to develop the theme as suggested in the Gatsby docs.

@cometkim
Copy link
Owner

Well, to be honest, I've been thinking about this recently while using the plugin for my work, and there's no clear answer yet.

The difficult part is that this plugin cannot run independently of the site as it depends on the fully Gatsby.js lifecycle.

@cometkim
Copy link
Owner

cometkim commented Mar 14, 2022

I've considered providing a separate binary including Gatsby's default schema, but considering that the Gatsby Theme composition can be very heavy and complex, it is not a realistic solution. It only makes sense when it's all configured.

My suggestion would be to emit the type from the actual configured site, but give it an extra option to put output closer to the theme. (e.g. multiple outputs, near-file-preset, etc)

Or assuming that themes are usually managed in monorepo, the Gatsby site emitting types can be operated as a library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants