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

Use proxies to avoid not defined error blocking compile #472

Closed
jasonkuhrt opened this issue Oct 13, 2019 · 8 comments · Fixed by #535
Closed

Use proxies to avoid not defined error blocking compile #472

jasonkuhrt opened this issue Oct 13, 2019 · 8 comments · Fixed by #535
Assignees
Labels
effort/modest needs/upstream An upstream component needs to be updated first scope/workflow type/feat Add a new capability or enhance an existing one

Comments

@jasonkuhrt
Copy link
Contributor

jasonkuhrt commented Oct 13, 2019

Analogy: Unused variable as error prevents build. At dev time this is annoying because an unused variable may just be a temporary state while working towards some idea, refactor, etc. It is much better at dev time to have this feedback at the level of just a warning, that does not block the compiler from building your code.

The idea is to implement the t.model operation publishers and t.crud field projectors as proxies so that when there is a sync issue or typo TS compile can still succeed. With proxies we can:

  • Provide custom error messages when the field doesn't exist (please sync etc.)
  • never get in the way of TS compiling, a golden rule

We may want a prod mode where proxies aren't used.

@jasonkuhrt jasonkuhrt added type/feat Add a new capability or enhance an existing one scope/generation labels Oct 13, 2019
@jasonkuhrt jasonkuhrt added this to Backlog in Labs Team via automation Oct 13, 2019
@jasonkuhrt jasonkuhrt moved this from Backlog to Sprint in Labs Team Oct 14, 2019
@Weakky Weakky moved this from Sprint to In Progress in Labs Team Oct 14, 2019
@Weakky Weakky added the needs/upstream An upstream component needs to be updated first label Oct 14, 2019
@Weakky
Copy link
Member

Weakky commented Oct 14, 2019

Currently blocked
Reason: Errors are printed twice because nexus runs dynamics twice (hence the needs/upstream label)

Will affect #479

@jasonkuhrt
Copy link
Contributor Author

Here is an example of the current frustration:

  1. I am trying to build the app but get this error:

    /Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/src/schema/Query.ts:5
        t.crud.blogs({
              ^
    TypeError: t.crud.blogs is not a function
        at Object.definition (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/src/schema/Query.ts:5:12)
        at SchemaBuilder.walkOutputType (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/nexus/src/builder.ts:1441:9)
        at SchemaBuilder.walkTypes (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/nexus/src/builder.ts:681:16)
        at SchemaBuilder.getFinalTypeMap (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/nexus/src/builder.ts:780:10)
        at makeSchemaInternal (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/nexus/src/builder.ts:1565:15)
        at Object.makeSchema (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/nexus/src/builder.ts:1610:49)
        at Object.<anonymous> (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/src/schema/index.ts:10:22)
        at Module._compile (internal/modules/cjs/loader.js:956:30)
        at Module.m._compile (/Users/jasonkuhrt/projects/prisma-labs/nexus-prisma/examples/blog/node_modules/ts-node/src/index.ts:493:23)
        at Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    error Command failed with exit code 1.
    
  2. So I go to the source code to see what's up

    image

  3. Sure enough, right, the static error. But now what? I want to know what are the actually available types. To achieve that, I need typegen, but I cannot produce typegen because of the type error...

@IzioDev
Copy link

IzioDev commented Nov 15, 2019

@jasonkuhrt Any workaround for this?

@jasonkuhrt
Copy link
Contributor Author

@izio38 the work around for now is fix all errors before continuing.

@IzioDev
Copy link

IzioDev commented Nov 16, 2019

@izio38 the work around for now is fix all errors before continuing.

I'm sorry, but I can't understand what errors needs to be fix. For some reason, the compilation just doesn't pass and I'm not able to see what else is wrong.
If there is no other way than commenting the t.model stuff it's fine, I'll do it :)

Thanks for the quick answer.

@jasonkuhrt
Copy link
Contributor Author

@izio38 Try commenting out all the errors, then incrementally bring them back and debug one by one.

@Weakky
Copy link
Member

Weakky commented Nov 18, 2019

the work around for now is fix all errors before continuing

I'm not sure I agree here? These are TypeScript errors. The "workaround" is just to run the server with ts-node --transpile-only or ts-node-dev --transpileOnly 🤔?

@jasonkuhrt
Copy link
Contributor Author

@Weakky right you are

Labs Team automation moved this from Blocked to Shipped Nov 19, 2019
@jasonkuhrt jasonkuhrt removed this from Shipped in Labs Team Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/modest needs/upstream An upstream component needs to be updated first scope/workflow type/feat Add a new capability or enhance an existing one
Projects
None yet
3 participants