Describe the bug
Using 1.5.0 and above results in a constant diff in output after each run.
I tested this both with 1.5.0 (prettier output, no hooks) and with the new hooks in released in 1.6.0 to format the generated file with prettier.
After each run, the generated file will diff only in ordering/sorting of type declarations and fields. This does not occur in [email protected] and below. The diff only being changes with sorting seemed weird to me, given the "rationale" of prettier: https://prettier.io/docs/en/rationale.html#what-prettier-is-not-concerned-about
I removed prettier and tested again and this doesn't occur. The output is consistent.
Hopefully, this helps with tracking it down!
To Reproduce
Steps to reproduce the behavior:
Update to 1.5.0, run codegen while using prettier to format.
Stage the files. Run codegen again. There's a diff. Repeat.
I'm using [email protected]
Unable to share 馃槥
Unable to share 馃槥
codegen.yml config file:With 1.6.0 and above:
overwrite: true
schema: src/schemas/**/typeDefs.ts
generates:
./src/types/codegen.ts:
hooks:
afterOneFileWrite:
- prettier --write
config:
useIndexSignature: true
contextType: ./GraphQLContext#GraphQLContext
namingConvention:
enumValues: change-case#upperCase
plugins:
- typescript
- typescript-resolvers
With 1.5.0 and below:
overwrite: true
schema: src/schemas/**/typeDefs.ts
generates:
./src/types/codegen.ts:
config:
useIndexSignature: true
contextType: ./GraphQLContext#GraphQLContext
namingConvention:
enumValues: change-case#upperCase
plugins:
- typescript
- typescript-resolvers
Expected behavior
Expect no diff in generated file when GraphQL typeDef files haven't changed
Environment:
@graphql-codegen/...: 1.5.0 and aboveAdditional context
@nathanchapman any chance you can create a reproduction in a repo? I tried to reproduce it, but it seems stable.
Hey!
The same for me:( But it looks like it is not related to the prettier...
Environment
System Version: macOS 10.14.3 (18D109)
Kernel Version: Darwin 18.2.0
NodeJS: v10.14.2
How to reproduce
Please see the code below:
https://github.com/shchekoldin/graphql-codegen-unstable-sorting-demo
it worth mentioning that there is no problem if all scalar related code is removed (see schema/modules/Common/schema.ts)... 馃う鈥嶁檪
This combination works fine 馃槃
...
"@graphql-codegen/add": "1.6.1",
"@graphql-codegen/cli": "1.4.1-alpha-00a59224.4+00a59224",
"@graphql-codegen/schema-ast": "1.6.1",
"@graphql-codegen/typescript": "1.6.1",
"@graphql-codegen/typescript-resolvers": "1.6.1",
...
@shchekoldin How about with 1.7.0 ?
@ardatan Same issue with 1.7.0
Having issues with unstable sorting as well, even without running prettier from codegen.
@shchekoldin How about with 1.7.0 ?
@ardatan Same issue with 1.7.0
Yep. Sorting is inconsistent(
Hello, we are also affected using 1.7.0. I'm not sure when the bug appeared since we have switched to graphql-codegen recently (we were using built-ins Apollo and NestJS generators before).
We are also using Prettier and removing the hook makes the generator consistent again, so it's definitely related to Prettier hook.
Could you try with the following version?
1.7.1-alpha-3e9c1264.63+3e9c1264
Could you try with the following version?
1.7.1-alpha-3e9c1264.63+3e9c1264
Works fine for me! Thanks a lot!
@ardatan That version works for me as far as consistency goes. I noticed a pretty large diff though (looks like it's not running the prettier hook at all)
@nathanchapman Could you create a reproduction?
Fixed in 1.8.0 馃殌
Confirmed it's consistent now! Thank you 馃帀
Most helpful comment
Fixed in 1.8.0 馃殌