deref/extractgqlts

Output requires formatting pass

Opened this issue · 0 comments

Presently, the each generated type is crammed on to a single line per type. For readability, you can run prettier on the output like this example:

#!/bin/bash

set +e

extractgqlts \
  --schema ./internal/resolvers/schema.gql \
  ./gui/src/**/*.svelte \
  > ./gui/src/lib/graphql/types.generated.ts

exit_code=$?
set -e

(
  cd gui
  node ./node_modules/.bin/prettier \
    --write \
    ./src/lib/graphql/types.generated.ts
)

exit $exit_code

However, compared to extractgqlts, prettier is extremely slow. For a non-trivial project, extractgqlts takes roughly than 0.02 seconds on my machine. Prettier on the one outputted file takes over half a second!

It would be much better if we output code that was already mostly formatted such that it could reasonably be configured for being ignored by prettier. This would require some sort of minimalistic AST for the output with a flattening pass that performs indentation.