-
Notifications
You must be signed in to change notification settings - Fork 115
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
fix: make codegen more robust #311
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally great changes! The error messages are already helpful, but can go one step further in terms of resolution pointers.
src/cmds/codegen/codegen.ts
Outdated
@@ -128,27 +127,41 @@ export class Codegen { | |||
} | |||
|
|||
if (generator === 'typegen') { | |||
|
|||
if (!output.typings || output.typings === '') { | |||
throw new Error("Please provide output.typings path to use typegen") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this error message actionable? How can I usually fix this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide output.typings path in graphql config to use typegen
- does this sound better? I basically want to notify the user that they need to provide the typings
option in the codegen
extension.
src/cmds/codegen/codegen.ts
Outdated
|
||
if (child.error) { | ||
if (child.error.message === `spawnSync apollo-codegen ENOENT`) { | ||
throw new Error(`Generator apollo-codegen is not installed.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this error message actionable? How can I usually fix this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we will not hit this at all with this new code!
src/cmds/codegen/codegen.ts
Outdated
@@ -158,16 +171,31 @@ export class Codegen { | |||
// fs.unlinkSync(tmpSchemaPath) | |||
} else { | |||
const args = ['--input', inputSchemaPath, '--language', language] | |||
|
|||
if (!output.binding || output.binding === '' && !output.typeDefs || output.typeDefs === '') { | |||
throw new Error("Please provide either output.binding or output.typeDefs to use this generator") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this error message actionable? How can I usually fix this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I want to notify that use that in codegen
extension, they need to provide either binding
or typeDefs
option to use this generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's add the reference to GraphQL Config again 🙂
Changes in terms of error message are done as suggested by @marktani Testing on windows is in progress. |
Not ready for windows yet, one of our Pondering a solution. |
npm-run 5.x is broken on windows we don't want to accidently merge it unless timoxley/npm-run#19 is resolved.
Current solution is to downgrade This is ready to be merged now. Please let me know if any changes are needed. Thanks! |
🎉 This PR is included in version 2.16.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Great job tracking this down, any chance to also downgrade npm run for prisma itself to make sure |
@ntziolis : I am trying to replicate the |
This PR does the following:-
Fail fast on any errors and notify the user about a potential fix
Refactor the logic to locate
apollo-codegen
binary to supporttypegen
Provide a default input value to
typegen
Downgrade
npm-run
to get around the regression on windowsI am testing this one one windows after which we can merge this and hopefully make our codegen users happy. Thanks!