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.

Type reflection issues

See original GitHub issue

Describe the bug Typescript metadata reflection does not seem to work at all. At first I thought it was related to the graphql adder, but it turns out that type-graphql works perfectly fine outside of sveltekit in an api folder served by vercel dev. This is not a permanent solution though considering there are existing issues pertaining to MIME types: #781.

Logs This is produced in both the response and the dev console (not browser).

Error when evaluating SSR module /src/resolvers/user.ts:
Error: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for argument named 'data' of 'register' of 'UserResolver' class.
    at Object.findType (/Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/helpers/findType.js:19:15)
    at Object.getParamInfo (/Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/helpers/params.js:10:49)
    at /Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/decorators/Arg.js:14:25
    at eval (/src/resolvers/user.ts:14:54)
    at __decorate (/src/resolvers/user.ts:9:24)
    at eval (/src/resolvers/user.ts:74:1)
    at instantiateModule (/Users/bobby/Documents/phorm-kit-vercel/node_modules/vite/dist/node/chunks/dep-66eb515d.js:69030:166) (x18)
Error: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for argument named 'data' of 'register' of 'UserResolver' class.
    at Object.findType (/Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/helpers/findType.js:19:15)
    at Object.getParamInfo (/Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/helpers/params.js:10:49)
    at /Users/bobby/Documents/phorm-kit-vercel/node_modules/type-graphql/dist/decorators/Arg.js:14:25
    at eval (/src/resolvers/user.ts:14:54)
    at __decorate (/src/resolvers/user.ts:9:24)
    at eval (/src/resolvers/user.ts:74:1)
    at instantiateModule (/Users/bobby/Documents/phorm-kit-vercel/node_modules/vite/dist/node/chunks/dep-66eb515d.js:69030:166)

To Reproduce Create a new sveltekit project, use graphql adder, and create an object and resolver using type-graphql. You can also look here: https://github.com/MirrorBytes/phorm-kit-vercel

Expected behavior For metadata reflection to function.

Information about your SvelteKit Installation:

System:
    OS: macOS 11.2.3
    CPU: (8) arm64 Apple M1
    Memory: 373.55 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.12.0 - /opt/homebrew/bin/node
    Yarn: 1.22.10 - /opt/homebrew/bin/yarn
    npm: 7.7.5 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 89.1.22.70
    Safari: 14.0.3
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.64
    svelte: ^3.29.0 => 3.36.0
  • Your browser Brave & Safari

  • Your adapter (e.g. Node, static, Vercel, Begin, etc…) Vercel

Severity How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of SvelteKit entirely?

It’s a hindrance to me and potentially anyone using TypeScript with decorators. I’m reproducing an existing project that currently exists in plain Svelte, so it’s just a mild inconvenience at the moment, but it’s ultimately blocking me from moving forward with SvelteKit.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Glenchcommented, Jan 9, 2022

Is there any update on this? TypeORM uses reflect-metadata and decorators which aren’t supported by esbuild apparently so it’s very difficult or maybe impossible to use one of the most popular ORMS with SvelteKit in addition to GraphQL 😦

It seems that maybe swc or some other builder could work, but there are no hooks in the sveltekit code that I’m aware of that can replace just the esbuild step. (Actually I don’t understand the architecture well enough to know if that sentence even makes sense.)

1reaction
gamelastercommented, Jan 10, 2022

@Glench I will try to look on this once again, I was trying to use TypeORM with SvelteKit too several months ago, but I had problem with Vite and esbuild too, although, there was some other issues with bundling too (which might still happen now?).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible reflection Issues with type-graphql mutations?
I've been trying to use type-graphql in a recent nodejs project. I've been able to successfully implement @Query methods but can't for the ......
Read more >
Are there problems with using Reflection?
No, it's not cheating - it is a way to solve problems in some programming languages. Now, it is often not the best...
Read more >
R8 obfluscation causing reflection issues - Zendesk help
Hello, I have a problem with obfluscation. I am using: - R8 version 3.0.73 (newest by default) - Gradle-tools 7.01 - Kotlin plugin...
Read more >
Java Reflection Example Tutorial - DigitalOcean
Poor Performance - Since java reflection resolve the types dynamically, it involves processing like scanning the classpath to find the class to ...
Read more >
Critical Reflection | Centre for Teaching Excellence
Without reflection, experience alone might cause us to “reinforce stereotypes…, offer simplistic solutions to complex problems and generalize inaccurately ...
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