Nexus: Properly document type generation

Created on 25 Mar 2019  路  5Comments  路  Source: graphql-nexus/nexus

I'm trying out nexus, coming from graphqlgen. I'm hoping to keep my strict TS settings as that's currently impossible with graphqlgen.

I've created a whole new project and made a workflow and already managed to break types with nexus.

Somehow, "the most important piece" is documented very, very little. Even compared to the rest of the docs.

Reading the https://nexus.js.org/docs/type-generation page leaves me as clueless as before. The source code is out of place too, why isn't there a nice table, like you'd expect and _do_ find almost(Stripe) everywhere(Apollo) else(Prisma)?

It seems to me that you've begun using nexus in the Prisma docs far too early. I'm really unsure on how to do anything else besides the exact path you're guiding me through.

I'm trying to do as follows:

  • Compile TS
  • Compile output with babel
  • Run node on babel's output
scopworkflow typdocs

Most helpful comment

Yep - will look to add docs for it this week. Glad it's working for you!

All 5 comments

I should probably clarify - I'm trying to have Intellisense on the resolve parameters for each field.

Such that parent, args and context are typed from the beginning.

With my setup, I've set typegenAutoConfig by following the example but that hasn't helped. There's not much else to do based on the documentation and I don't even know if this is possible.

I've done this with graphqlgen and it seems Prisma updates and changes everything every month and nexus is the next thing after graphqlgen. Please correct me if I'm wrong... Nexus is the thing in the docs atm and graphqlgen is quite dead - it's really hard to figure out what you're doing internally or what the current best practice is.

The types will be generated when makeSchema / makePrismaSchema is called. So you need to run your code at least once to get types. I'd recommend using some sort of "watch" tool that re-executes your code every time you make a change so the types get recreated by nexus and stay up to date, one option is ts-node-dev like in that example you linked.

Also make sure your outputs paths are configured correctly, the .ts file created by nexus needs to be in a folder included in your .tsconfig (I put mine in src/generated/nexus.ts).

You mention you are compiling your code using babel and then running the output so the paths will be relative to the .js file output by babel not relative to the .ts file keep that in mind when setting up your paths.

Oh my! I've forgotten to add the generated folder to the include in tsconfig.json. The rest is running just fine with watch flags on tsc and babel. Thanks for the quick reply, even though my issue is filled with negativity and poor explanations.

I still like tables for the reference though. It's really annoying having to scroll around and actually locate specific information - instead of looking at a compact table where everything is succinctly explained. I'm quite sure the JSDoc notation can be used.

This is awesome btw! As soon as it worked and after having looked at nexus for some hours - it's really amazing how everything works to give the developer much more oversight and a great experience.

Yep - will look to add docs for it this week. Glad it's working for you!

This will be better addressed by #242

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdrackett picture chrisdrackett  路  3Comments

santialbo picture santialbo  路  5Comments

delianides picture delianides  路  6Comments

tonyfromundefined picture tonyfromundefined  路  3Comments

DregondRahl picture DregondRahl  路  3Comments