dotansimha / dotansimha/graphql-code-generator
Write generated schema to stdout
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Is your feature request related to a problem? Please describe.**
Contributors to our project sometimes manually edit the generated schema. We'd like to implement a checker that can diff the current state of the output file with the output generated by running `graphql-codegen`.
My idea is that in CI (or a pre commit hook etc) we can do something like:
`graphql-codegen --config foo.yml --stdout | diff schema.ts`
in order to detect whether the generated file is 'up to date' with the source files used to generate the schema.
Eg. Contributor A edits `schema.ts` directly but not the underlying `foo.types.ts` used to generate it. We want to detect this and alert the user.
**Describe the solution you'd like**
A flag or something that allows me to output to stdout so I can pipe to another program, instead of outputting to a file.
**Describe alternatives you've considered**
I've considered copying the current file to a temp dir, generating the schema, renaming the newly generated schema, copying the original file back, but this is brittle and cumbersome to maintain.
**Additional context**
One consideration is that a single `--stdout` flag won't work for users with more than one entry in `generates` in their config. Perhaps it should take an argument which specifies the name/index of the schema under `generates` that should be generated?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.