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

Discussion about developer experience #77

Open
kandros opened this issue Mar 8, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@kandros
Copy link
Contributor

commented Mar 8, 2019

Nexus uses a particular approach to deal with typechecking, that involve generation of typings types files from "runtime defined objects" that extend a global "object type" that nexus itself uses to typecheck other types.

This is meant as a discussion to find problems related to developer experience and a possible solution to address them.

@kandros

This comment has been minimized.

Copy link
Contributor Author

commented Mar 8, 2019

a personal scenario:
server is crashed or not running and the update of generated typings files is no longer happening, so the typechecking 'feels' broken

@tgriesser

This comment has been minimized.

Copy link
Collaborator

commented Mar 11, 2019

a personal scenario:
server is crashed or not running and the update of generated typings files is no longer happening, so the typechecking 'feels' broken

Yes, I agree this should be better dealt with. Possibly with an editor extension that checks whether the Nexus server is running?

Ping @Weakky to see if you've had any thoughts around this with yoga2.

@Weakky

This comment has been minimized.

Copy link
Collaborator

commented Mar 11, 2019

Had a similar issue on nexus-prisma recently: prisma/nexus-prisma#183 (comment)

TLDR: The user is complaining that he's forced to start his server before being able to build it.

  • As yoga2 has a build command in its CLI, one thing I'm planning to do is to programmatically run the type generation before building the project to make sure they're up-to-date.

  • Another potential fix to better the experience is that TS proposal: microsoft/TypeScript#23689

    If I do understand it properly, we could use invalid('Please, start your server to update generated types') instead of all these any fallbacks that we use in the conditional types to not break the app if types aren't there.

  • An extension could also be an option, we could also pack it with the SDL comments we've been talking about prisma/yoga2#33 since a long time, instead of messing with people's file as we're planning to do. I'm just a bit concerned that people will complain they'll need an extension just to have a good experience with the library

Apart from these hints, I could not come up with a better solution til now 😕

@tgriesser

This comment has been minimized.

Copy link
Collaborator

commented Mar 11, 2019

TLDR: The user is complaining that he's forced to start his server before being able to build it.

I recommend running your normal development server in transpile-only mode via the -T flag to ts-node or similar (isolatedModules option, etc.).

Then have a separate process which actually is checking the types. Usually I'll do this as part of CI rather than locally, but you could come up with a script to do this locally as well. Maybe it's worth setting up some gulp scripts that set this sort of thing up out of the box?

@kandros

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

using --transpile-only is indeed very useful.

probably most of the possible solutions make more sense to be in yoga2 given how invasive they can be like inserting inline comments when some common errors are found using AST manipulation so that it can be editor agnostic

@kandros

This comment has been minimized.

Copy link
Contributor Author

commented Mar 30, 2019

During today's OpenSourceSaturday meetup in Milan, when demoing for nexus to some persons I (once again) felt in subtle DX issues that hit me in the face all the time :D

  • Forgetting to run Server (thus generating new typings)
  • Forgetting to add name parameter in objectType resulting in a not-so-friendly error message

I'm experimenting is prevent these and other minor problems related to very hard to debug typings error with an eslint plugin https://github.com/kandros/eslint-plugin-nexus.

I'm very far from proficient in eslint rules development especially related to TS parser, if someone could guide me in the right direction I would love to dedicate some time in making nexus development experience easier in the day-by-day (some TS errors are just too much to deal with after lunch 😁 when there are 10+ generics involved)

https://twitter.com/kandros5591/status/1112014449924337664

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.