graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Errors during generation are non-existent

Open chriswetterman opened this issue 2 years ago • 3 comments

Describe the bug

I've recently updated to v2 of the CLI and the associated plugins. Since then the errors that are reported are not helpful in that only a partial of the error is displayed. This makes tracking down errors extremely more challenging. Please see the below screenshots and information. I have used the debug and errorsOnly flags and they do not provide any additional information toward identifying the reason and therefore cause of the failure.

Your Example Website or App

None provided

Steps to Reproduce the Bug or Issue

To reproduce I have the following CLI version and plugins installed which at the time are the most current versions. Create a query/mutation that is incorrect or doesn't exist to cause any error in generation. Review the reported errors.

Expected behavior

As a user, I am expecting to see detailed enough errors to allow me to track down my errors to resolve. Version 1 of the CLI provided adequate information around errors.

Screenshots or Videos

image image

Platform

To reproduce I have the following CLI version and plugins installed which at the time are the most current versions.

Codegen Config File

schema:
  - https://graphql-federated-gateway...../graphql
  - 'schema.graphql'
documents: './src/**/*.graphql'
generates:
  ./src/generated/graphql.tsx:
    config:
      enumsAsConst: true
    plugins:
      - typescript
      - typescript-operations
      - typed-document-node

Additional context

No response

chriswetterman avatar Sep 19 '22 20:09 chriswetterman

I am seeing the same issue, errors are no longer being displayed. The only thing I get is the following statement Unable to validate GraphQL document!, but where it is, is not being shown. It did do this before.

wesselvdv avatar Sep 20 '22 12:09 wesselvdv

@chriswetterman, I tested a similar setup locally. GraphQL Code Generator relies on Listr for console output, which truncates the content of logs depending on your terminal width (at print time, not dynamically). To avoid this, I recommend that you run codegen in verbose mode, as follows:

yarn graphql-codegen -r dotenv/config -v

charlypoly avatar Sep 22 '22 13:09 charlypoly

Hi @charlypoly, I added the verbose flag and didn’t see any change in the output as it’s still truncated. Again this is in VS Code and I tried in both powershell and bash terminals.

chriswetterman avatar Sep 22 '22 13:09 chriswetterman

@chriswetterman, okay, we will investigate further.

@wesselvdv, do you also face this issue on Windows or on another OS?

charlypoly avatar Sep 23 '22 10:09 charlypoly

two thumbs way up

hannahborel avatar Sep 23 '22 12:09 hannahborel

@charlypoly We have another project that's on [email protected] and it reports a plethora of errors as expected and I've rolled back to that for now. I just tested on [email protected] and the issue still persists (our Nexus repo doesn't have 2.13.5 yet to test). Currently don't have the bandwidth to narrow down exactly which release the issue began with but hopefully this gives you some more info. I'll circle back when things free up on my end. Thanks.

chriswetterman avatar Oct 06 '22 14:10 chriswetterman

It appears graphql-codegen/[email protected] introduced the issue

chriswetterman avatar Oct 09 '22 04:10 chriswetterman

Hi @hannahborel, @wesselvdv,

Could you confirm that you also face this bug only on Windows? I could not reproduce it on MacOS.

charlypoly avatar Oct 10 '22 08:10 charlypoly

@charlypoly I can confirm downgrading the version to 2.9.0 is working well on Mac. If I install version 2.10.0 or above it doesn't work.

wzalazar avatar Oct 12 '22 03:10 wzalazar

I can also confirm that the issue occurs on macOS as well. Reverting the CLI to 2.9.0 does indeed fix it and reintroduces error information in addition to just "Unable to validate GraphQL document!".

pleunv avatar Oct 18 '22 10:10 pleunv

Hi all,

The culprit is most likely the following commit: https://github.com/dotansimha/graphql-code-generator/commit/e2cfc5c360d09a4ba98d8855769b8711c96f13b2

However, reverting this commit will bring back another bug that printed all error messages twice.

The root cause of the error truncating issue seems to be linked to our migration to Listr2, which I experienced, which seems to truncate all logging containing multiple lines.

There is no easy fix regarding this issue, and we prioritize it as one of the first things to tackle as part of the v3 roadmap.

charlypoly avatar Oct 24 '22 08:10 charlypoly

Much appreciated, @charlypoly. Thank you and looking forward to v3.

chriswetterman avatar Oct 24 '22 09:10 chriswetterman

Hi @chriswetterman, hi all,

Could you give a try to the following canary release of @graphql-codegen/cli?

Package Version Info
@graphql-codegen/cli 2.13.8-alpha-20221025134913-ec8a36be2 npm ↗︎

It should fix the issue of error truncating on Windows and also most of the issues of error details on all platforms.

charlypoly avatar Oct 25 '22 13:10 charlypoly

@pleunv @wesselvdv @chriswetterman @hannahborel, any feedback with the canary version suggested above?

charlypoly avatar Oct 27 '22 09:10 charlypoly

@charlypoly I just encountered this problem, and tried out the changes you made in #8525, and they do appear to resolve the issues.

mvestergaard avatar Nov 01 '22 09:11 mvestergaard

A fix has been released in @graphql-codegen/[email protected] 📦 Please make sure to also update all your @graphql-codegen/* packages.

charlypoly avatar Nov 01 '22 11:11 charlypoly

@pleunv any feedback with the canary version suggested above?

Apologies, completely missed this. Just want to confirm that this does in fact also fix the issue for us. Thank you!

pleunv avatar Nov 04 '22 10:11 pleunv