Make errors thrown more descriptive #2686
Merged
+4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theerrors
'sdetails
field, later calledmsg
, 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:The error after my fix:
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 💪🏼