You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
The order of some properties does seem indeterministic. I decided to track the file in Git, as I have a Git Hook in place to build all TypeScript which relies on the generated types and I want to be sure it works without having to run gatsby develop beforehand. Unfortunately the output doesn't seem deterministic, so the file has changes because the order of properties in the types changes.
I might be wrong about this but I'm not sure how much control we have over the order of the properties because I believe this is handled upstream in graphql-code-gen.
Instead, I'd like to see if we can figure out a way to generate the types without having to run the whole build.
At my work, I think we faced a similar problem that you're facing. We use and deploy storybook which relies on the generated gatsby types but we don't want to run the whole gatsby build in order to get those types. Instead of checking in the generated types, we copied the basic logic of this codegen plugin in gatsby-node.js and added this check after the codegen ran:
constcliArgs=process.argv.slice(2);exports.createPages=({ store, reporter }){const{ schema }=store.getState();// do codegen…// 👇👇👇if(cliArgs.includes('--die-on-codegen')){process.exit(0);}// rest of create pages…}
I'm not super happy with this solution but afaik, there is no way to get the schema from gatsby without running the build so it's the best I've got.
So TL;DR, I would prefer figure out some way to generate the types without running the build but I'm not too sure if there's an elegant way to do so.
So some questions for you:
Would figuring out a way to generate types without running the build solve your problem?
Do you really need consistent build output? (then might be an issue for upstream them, I might be mistaken though)
If generating the types without running the build will solve your problem then I think adding a special flag like --die-on-codegen will work if we're okay with it's weirdness. This issue would be related to #29.
The order of some properties does seem indeterministic. I decided to track the file in Git, as I have a Git Hook in place to build all TypeScript which relies on the generated types and I want to be sure it works without having to run
gatsby develop
beforehand. Unfortunately the output doesn't seem deterministic, so the file has changes because the order of properties in the types changes.Example of such a diff:
The text was updated successfully, but these errors were encountered: