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.

[BUG] Resolver/Services(Injectible) package is missing.

See original GitHub issue

Information

  • 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).

  1. I’m trying to make the path importing from a relative into absolute.
  2. On the tsconfig compiler, I changed the baseUrl, made changes to have relative --> absolute.
  3. 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.
  4. 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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
navalta3030commented, Dec 7, 2021

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!

1reaction
Romakitacommented, Dec 7, 2021

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!

Read more comments on GitHub >

github_iconTop 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 >

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