Open jasonkuhrt opened 4 years ago
Legend
Runtime typegen
postInstall
npm hook to run nexus typegents-node
or ts-node-dev
need to be used with --transpile-only
option and typechecking needs to be done via a separate process (commonly handled via VSC tsc process)
nexus dev
command. One simple solution.Type-checking
:question: Cryptic type-check error messages (due to conditional typings)
🔵: Input properties needs to be inputted in a certain order to make things smooth. (eg: name
property needs to be define first for the definition
type-checking to work properly in objectType
/inputObjectType
etc)
objectType('typeName', { ... })
to force inputting the name
before the rest 😕t.field
t.field
& no more typechecking issues.Pagination
t.relayConnection()
with Photon
pageInfo
as suggested in the issueNexus two phases (walk & build)
currentPhase
to plugins to make sure to log only oncePrisma integration
prisma2 dev
& ts-node-dev
)
nexus dev
somehow run prisma2 dev
prisma2 dev
& ts-node-dev
not working well together (supposedly because some files are read by both processes). (Feedback given by tom during our internal hackathon)General
makeSchema
option to customize the global interface namecontextType
https://github.com/prisma-labs/nexus/issues/265
typegenAutoConfig.sources
)
nexus build --target="heroku|lambda"
command🔵User needs to manage additional deps to accomplish this workflow (ts-node-dev
, ts-node
)
💡Nexus cli $ nexus dev|build
can hide them
🔵User needs to remember the right flags to use on ts-node-dev
(--transpile-only
, --tree-kill
) and they need to understand why.
Example: user resisting/insecure about --transpile-only
💡Nexus cli $ nexus dev|build
can hide this
🔴Generated artifacts in node_modules
may get pruned
💡Facades for photon https://github.com/prisma/photonjs/issues/261
💡Facades for nexus typegen https://github.com/prisma-labs/nexus/issues/253
💡Nexus typegen hook for plugins so that nexus facade solution can be benefit all plugins
🔴If the user configures --types
compiler option their app will no longer automatically use typegen. There will be no feedback about why typegen has stopped working. The user will need to realize that 1) typegen goes into @types and that 2) types compiler option turns that into an opt-in/whitelist.
💡Nexus cli can use TS compiler api programmatically to inject typegen into types
option. This will however not help the IDE.
💡VSC plugin that takes the above solution into the IDE too?
💡New cli sub-command $ nexus doctor
that looks for problems such as this and tells the user how to fix them.
💡VSC plugin that enables doctor at all times so user does not need to remember to run $ nexus doctor
🔴There are no docs on workflow patterns and what environment variables have what effects when.
💡Add a new workflow sub-section under nexus reference docs https://github.com/prisma-labs/nexus/issues/96
🔵User has to maintain at least two terminals, one for prisma dev and one for application dev (ts-node-dev). When they have a t.model or t.crud static error that they don't expect, they need to go through each terminal to find the issue: 1) Did photon fail to build for some reason? 2) Is my app failing to build for some reason (and thus typegen)?
💡Have nexus dev
use @prisma/sdk
to programatically drive prisma dev.
🔵When starting a project it is often not obvious what combination of dependencies are needed to get what one can see working in an example (e.g. prisma 2 alpha, nexus beta, nexus-prisma regular release).
Unable to get into a state like described here:
🔴User can modify app code such that nexus/nexus-plugins generation cannot succeed. This is because nexus generation relies on actually running all definition blocks in the source code. Having generation blocked because the app will not run is arguably reasonable if the reason the app will not run is due to a syntax error or some runtime error unrelated to prisma. But it is not reasonable if there is a runtime error from trying to use nexus-prisma in the correct way.
Actually prisma dev
emitting into node_modules
is triggering ts-node-dev
, even when ts-node-dev
is run with --ignore-watch node_modules
.
🔵User needs to manually coordinate a nexus generate following a prisma generate
For example if user boots upprisma dev
andts-node-dev ...
in two separate terminals, there is a race condition. Ifprisma dev
is slower, user will need to trigger a reload ofts-node-dev
e.g. save on any source file.
Maybe this is because the dependency graph is being watched as per mentioned in ts-node-dev readme:
It restarts target node process when any of required files changes (as standard node-dev)
🔴Users must apply a specific combination of tools and configurations thereof to successfully build their app "the nexus way".
NEXUS_CONFIG='{...}'
)ts-node
ts-node
the right flags (--transpile-only
)ts-node
just the entrypoint to your schema, not servertsc
Example: user not realizing they need special env var to trigger typegen on heroku deploy
💡We can remove iv
with https://github.com/prisma-labs/nexus/issues/272, a new config option to exit the process after artifact generation.
💡Nexus cli $ nexus build
can abstract all other steps
🔴Many deployment platforms impose idiosyncratic mechanisms for how users need to structure their application. Often this structuring is not at the code level but project layout level or build pipeline. Because Prisma and Nexus use code generation techniques, users of these tools often fall victum to deployment platforms not expecting this novel-ish workflow. While we could say its not our problem, the bottom line is users experience pain, and theym ay well blame that pain on the technique of generation rather than the deployment tools.
npm run build
scriptnpm run now-build
scriptnetlify
, lambda
...lambda
example: https://github.com/prisma-labs/nexus/issues/278
💡An example for each platform
💡For AWS Lambda, a serverless framework plugin
💡For zeit, a custom builder wrapping the nodejs one
🔵 In all of the above, because it all relies on integration of tools, the workflow that is being put together is not encoded, but rather implicit. That means error messages are never going to be in the domain of the workflow, but siloed and generic to the various tools.
Another example, again during build, if something goes wrong during the typegen attempt, they will just see a big general ts-node or something error, probably a stack trace, etc. It would be nice if they could see a clear message "Error while building Nexus app. Failied on typegen step. Here was the error: ...".
💡Nexus cli $ nexus build|dev
can encode the workflow between tools, introduce domain error messages.
🔵NODE_ENV has effect on "develop mode" even after build. This can lead to unexpected errors. For example a user thought that there was a bug because require.resolve
used on a ts file for makeSchema({ contextType })
config would lead to a path to a JS file after build. In turn this would lead to an error in typegen which asserts the file path must be to a .ts
extenson file. Actually what happened was the user was running e.g. node dist/index
with not NODE_ENV=production
. These integration effects are unpredictable to most users and even if they don't always represent a valid combination of states users generally cannot be expected to know every permutation of this. It should just be impossible for them to get into these states in the first place.
https://github.com/prisma/prisma-examples/pull/867#issuecomment-545400592
💡Nexus cli $ nexus build
can inject special code that disables dev features. This would only help TS users since presumably JS users do not need $ nexus build
.
@Weakky
🔵 Forgetting to run Server (thus generating new typings) prisma-labs/nexus#77 (comment) 💡Have a separate process always generating typegen
What does that solution mean/how could it help exactly?
🔵 No type-checking after cloning a repo 💡 Use postInstall npm hook to run nexus typegen
The best we could do with that solution is for it to be a pattern we suggest right? Since it would be app-level.
Cons: Less composable. We already have composability issues with t.field
We could allow the object version too, thus being backwards compatible. And that is nicer for machine use-cases as we identified the other night with t.field
.
🔴 Runtime error prevents typegen from being re-run, thus making the typechecking desync/broken
How could this be fixed, though?
What does that solution mean/how could it help exactly?
We could, for instance, have a VSC plugin running the typegen in the background, so that it's independent of the runtime.
The best we could do with that solution is for it to be a pattern we suggest right? Since it would be app-level.
Yes. "Encoding" that pattern in all examples + documenting it might be the best solution here
We could allow the object version too, thus being backward compatible. And that is nicer for machine use-cases as we identified the other night with t.field.
Still wondering whether it's a good idea to have two APIs to achieve the same thing. Might be confusing for users
How could this be fixed, though?
I don't think we can, hence why I labeled it as 🔴 (Trap)
More since here https://github.com/prisma-labs/nexus-prisma/issues/523
Would love a VSC plugin to generate types
We have consolidated the issues in this epic to an organized notion table. It is public.
When this issue is resolved we should be able to mark the following as resolved too: