StellateHQ / fuse

Fuse: The fastest way to build and query great APIs with TypeScript

Home Page:https://fusedata.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: Run prettier over generated files if a config exists

mxstbr opened this issue · comments

Summary

Every time I run dev my VSCode sidebar looks like this, even if I haven't changed anything about my schema:

CleanShot 2023-12-15 at 10 07 26@2x

This happens because I use prettier, which formats files differently than the codegen.

Proposed Solution

If there is a prettier config file in the folder or a parent folder, run prettier over the generated code with the actual config to avoid unnecessary git diffs.

This should be implemented in GraphQL Code Generator, we basically have to detect whether the user has either got prettier installed (no config) or has a prettier config and then add the following to the GraphQL Code Generator process.

  hooks: { afterAllFileWrite: ['prettier --write'] }

On it :)