Closed cometkim closed 2 years ago
Thank you @jazevedo620 for leaving feedback here.
It sounds pretty bad for me that gatsby develop and gatsby build produce different schema/types. Can you share your site configuration?
Maybe I can add a flag to exit process after all tasks are done once. Or I guess to add fork-ts-checker webpack plugin could integrate type-checking to gatsby build seamlessly.
The schema and documents outputs are stable since v3.
I will open another issue for further enhancement on CI env
Hey, just wanted to leave some feedback on CI using
gatsby-plugin-typegen
from the perspective of the project I'm working on. In our repo, we exclude the generated types from version control, and instead let them get generated upon the first run. Part of the reasoning for this is that we usegatsby-source-graphql
with the GitHub API, which causes the generated schema to (expectedly) include the entire GitHub API GraphQL schema. Because of this, we have to build the site before running ESLint ortsc
during CI. In my experience, runninggatsby develop
andgatsby build
causes different types to be generated, so builds on CI will fail when they rungatsby build
beforetsc
to typecheck.A workaround I made for this is to have a script run
gatsby develop
on CI and kill the process once it successfully finishes (otherwise it would keep running to serve the dev server). This allows us to run this before typechecking/linting and correctly mirrors the same types that are generated while developing.In the future, it would be useful if
gatsby develop
andgatsby build
didn't produce different types, though I'm sure there are technical reasons that this is the case. Alternatively, it would also be convenient to have some way to run the code generation for the schema in a way that didn't involve the entire site build, so that it would be faster in CI. However, I know that the schema generation is tied to the internal schema built by Gatsby at runtime, so I'm not sure how possible this is (perhaps the build could be forcibly stopped at some point in the Gatsby build lifecycle after the codegen runs and before the bundles are made/rendered).