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

fix: make codegen more robust #311

Merged
merged 7 commits into from
Jun 1, 2018
Merged

fix: make codegen more robust #311

merged 7 commits into from
Jun 1, 2018

Conversation

divyenduz
Copy link
Contributor

@divyenduz divyenduz commented May 31, 2018

This PR does the following:-

  1. Fail fast on any errors and notify the user about a potential fix

  2. Refactor the logic to locate apollo-codegen binary to support typegen

  3. Provide a default input value to typegen

  4. Downgrade npm-run to get around the regression on windows

I am testing this one one windows after which we can merge this and hopefully make our codegen users happy. Thanks!

Copy link
Contributor

@marktani marktani left a 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.

@@ -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")
Copy link
Contributor

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?

Copy link
Contributor Author

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.


if (child.error) {
if (child.error.message === `spawnSync apollo-codegen ENOENT`) {
throw new Error(`Generator apollo-codegen is not installed.`)
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@@ -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")
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 🙂

@divyenduz
Copy link
Contributor Author

Changes in terms of error message are done as suggested by @marktani

Testing on windows is in progress.

@divyenduz
Copy link
Contributor Author

Not ready for windows yet, one of our sub-deps is broken for windows - timoxley/npm-run#19

Pondering a solution.

Divyendu Singh added 2 commits May 31, 2018 14:49
npm-run 5.x is broken on windows

we don't want to accidently merge it unless
timoxley/npm-run#19 is resolved.
@divyenduz
Copy link
Contributor Author

Current solution is to downgrade npm-run to 4.x. I can confirm that it works on windows now, I also added npm-run to ignoreDeps in renovate.json so that we don't accidentally update it.

This is ready to be merged now. Please let me know if any changes are needed. Thanks!

@schickling
Copy link
Contributor

🎉 This PR is included in version 2.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ntziolis
Copy link

ntziolis commented Jun 1, 2018

Great job tracking this down, any chance to also downgrade npm run for prisma itself to make sure prisma deploy actually creates the post deployment files?

@divyenduz
Copy link
Contributor Author

@ntziolis : I am trying to replicate the prisma deploy not calling hooks issue on windows and will fix that after successful reproduction.

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

5 participants