Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output requires formatting pass #1

Open
brandonbloom opened this issue Mar 22, 2022 · 0 comments
Open

Output requires formatting pass #1

brandonbloom opened this issue Mar 22, 2022 · 0 comments

Comments

@brandonbloom
Copy link
Member

brandonbloom commented Mar 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant