question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable typegen by default in development

See original GitHub issue

I think the Nexus defaults for typegen should be more helpful. I propose the following:

  1. Enabled by default when NOT production
  2. Output to node_modules/@types/typegen-nexus/index.d.ts

We learnt from Nexus Framework that these are great defaults.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonkuhrtcommented, Nov 29, 2020

You should run ts-node-dev with transpile only flag

1reaction
calirvinecommented, Nov 29, 2020

Disclaimer: This could be entirely due to misconfiguration on my side, I find the makeSchema config object a bit confusing.

I’ve run into some trouble when leaving my typegen output out of source control, and that is that I lose portability of the project. When I clone my repo to another environment, I run npm install and prisma generate which generates my prisma types fine, but when I start my project I get a lot of typescript type errors, usually on objectTypes that use custom scalars.

i.e

TSError: ⨯ Unable to compile TypeScript:
src/schema/story.ts:20:7 - error TS2339: Property 'json' does not exist on type 'ObjectDefinitionBlock<"Story">'.

20     t.json('body')

If I comment out the field, allow the project to run successfully, the scalar is added to my generated types and I can then uncomment the field and it works as expected.

I’m assuming this could be fixed by keeping generated types in source control (currently I keep them in the recommended node_modules/@types/typegen-nexus/index.d.ts) but I could be wrong, and this might be unrelated to this discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable typegen by default in development - - Bountysource
Enabled by default when NOT production; Output to node_modules/@types/typegen-nexus/index.d.ts. We learnt from Nexus Framework that these are great defaults.
Read more >
GraphQL Typegen - Gatsby
By default, this feature is only generating files during gatsby develop . ... In the context of GraphQL Typegen fragments enable you to...
Read more >
TypeGen attributes
TsDefaultExportAttribute¶. Used to specify if the generated TypeScript type should use a default export. There is also a possibility to enable default exports ......
Read more >
Plugins configuration - Strapi Developer Docs
Enabled by default in if NODE_ENV is set to development . Boolean, false. shadowCRUD, Whether type definitions for queries, mutations and resolvers based...
Read more >
makeSchema - GraphQL Nexus
7 typegen: path.join(__dirname, 'generated/nexusTypes.gen.ts'), ... There is no default behavior for this, but you could do something like the following, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found