[BUG] Resolver/Services(Injectible) package is missing.
See original GitHub issueInformation
- Version: 6.94
- Packages: common, graphql.
A few sentences describing the overall goals of the issue.
Resolver
import { Inject } from "@tsed/di";
import { ResolverService } from "@tsed/graphql";
import { UsersService } from "services/usersService";
import { Query } from "type-graphql";
@ResolverService()
export class UsersResolver {
@Inject()
private usersService: UsersService;
@Query(() => [String])
async getAllUsers(): Promise<string> {
console.log(this.usersService);
return "Hello";
}
}
Service (the usual one).
import { AfterRoutesInit, Injectable } from "@tsed/common";
import { TypeORMService } from "@tsed/typeorm";
import { Connection } from "typeorm";
@Injectable()
export class UsersService {
private connection: Connection;
constructor(private typeORMService: TypeORMService) {}
.
.
.
}
Server.ts
import "@tsed/platform-express";
import "@tsed/typegraphql";
import "@tsed/ajv";
import "@tsed/typeorm";
import { Inject } from "@tsed/di";
import { PlatformApplication, Configuration } from "@tsed/common";
import bodyParser from "body-parser";
import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";
import cors from "cors";
import typeormConfig from "./config/typeorm";
export const rootDir = __dirname;
@Configuration({
componentsScan: [`${rootDir}/gql/**/*.ts`],
typegraphql: {
default: {
path: "/graphql"
}
},
rootDir,
acceptMimes: ["application/json"],
httpPort: process.env.PORT || 8083,
httpsPort: false,
typeorm: typeormConfig,
exclude: ["**/*.spec.ts"]
})
export class Server {
@Inject()
app: PlatformApplication;
@Configuration()
settings: Configuration;
$beforeRoutesInit(): void {
this.app
.use(cors())
.use(cookieParser())
.use(compress({}))
.use(methodOverride())
.use(bodyParser.json())
.use(
bodyParser.urlencoded({
extended: true
})
);
}
}
tsconfig.compiler.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"rootDirs": [
"src"
],
"outDir": "./dist",
"moduleResolution": "node",
"declaration": true,
"noResolve": false,
"preserveConstEnums": true,
"sourceMap": true,
"noEmit": false,
"emitDeclarationOnly": true,
"inlineSources": true,
},
}
What caused it (It was working before I made changes).
- I’m trying to make the path importing from a relative into absolute.
- On the tsconfig compiler, I changed the baseUrl, made changes to have relative --> absolute.
- Now it’s saying
src/gql/resolvers/usersResolver.ts" package is missing. at importPackage (/Users/mark/Desktop/resolvex/dashboard/packages/account-service/node_modules/@tsed/core/src/utils/imports/importPackage.ts:6:13)
I think is a little bit misleading error based on past experience, I think the error is hidden within when it tries to loads the resolvers and failed to do so. - On the error, the file path it shows that is missing is correct within the file system.
Acceptance criteria
- Be able to yarn start
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Improve error message for when Injectable() is missing #12467
If component A has a dependency on service B, but service B does not have the Injectable() decorator defined, a vague error message...
Read more >E-PUM: When Defining a Change Package by Image Level ...
E-PUM: When Defining a Change Package by Image Level, Some Bugs are Missing or Not Included in the Change Package (Doc ID 2588701.1)....
Read more >A Realistic Bug Injection Methodology for Benchmarking Fuzz ...
To ease the construction of such a benchmark, this paper presents FIXREVERTER, a tool that automatically injects realistic bugs in a program. FIXREVERTER...
Read more >Creating subscription for missing operator package causes ...
I was installing 10 operators into the cluster, and if the 3rd operator package was missing, none of the subsequent 7 operators would...
Read more >fail build. missing file: 'test/data/webui_test_resources.grd'
Issue 515917: fail build. missing file: ... missing files in the 46.0.2467.2 tar.xz ... please re-open or file a new bug if this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ended up not using absolute path, but the error was misleading. The root reason was because you are right, it’s not able to import the correct one on the bundled files.
On ImportPackages.js I modified to throw new Error(e) instead of the hard coded string, that’s when I knew it was absolute path error.
Thanks!
Use absolute path is dangerous. I don’t use it because, it depend on node module resolutions. Also the absolute paths will be wrong if you compile your code!