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

Make errors thrown more descriptive #2686

Merged
merged 2 commits into from
Oct 5, 2019
Merged

Make errors thrown more descriptive #2686

merged 2 commits into from
Oct 5, 2019

Conversation

JureSotosek
Copy link
Contributor

@JureSotosek JureSotosek commented Oct 4, 2019

Hey hey 👋🏼, first of all, I want to say I love graphql-code-generator, I have been using it a lot lately and it has made my life so much easier 😅I want to help improve it so here is my little contribution, hope you consider it 🤞🏼

The problem I had:
I was working on one of my projects when I decided to add the typescript-react-apollo plugin. It keept throwing an error (Plugin "typescript-react-apollo" validation failed:), which is kind of undescriptive.

After digging into the code I figured out the problem but also realized that there are details to the errors that are not being displayed. Especially in my case, it would have really helped me out.

My solution
Display the details of the errors and make it easier for the user to debug their program.

The listr-renderer.ts now includes the errors's details field, later called msg, in all of the errors that are being thrown.

Example
The problem I was having was that typescript-react-apollo requires that the extension of the generated file is .tsx. So the error I was getting before was:

Screenshot 2019-10-04 at 20 53 49

The error after my fix:

Screenshot 2019-10-05 at 12 03 11

Way clearer, in my opinion!

Also, here's the repo of the example from above: https://github.com/JureSotosek/graphql-codegen-errors-example

Let me know what you think 💪🏼

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@JureSotosek JureSotosek changed the title Make error.details visible in all errors thrown Make errors thrown more descriptive Oct 4, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@dotansimha
Copy link
Owner

Thank you @JureSotosek ! I think we changed it during the last version fixes, and never changed it back.

@dotansimha dotansimha merged commit 99aa17f into dotansimha:master Oct 5, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants