Type-graphql: Cannot find wildcard import module in buildSchema

Created on 5 Aug 2019  路  4Comments  路  Source: MichalLytek/type-graphql

Hi,

I'm trying to do the wildcard import as described in the docs, but it continuously throws an error cannot find the module.

Code I'm using
```import { buildSchema } from "type-graphql";

async function bootstrap() {
const schema = await buildSchema({
resolvers: [__dirname + "/*/.resolver.ts"],
});

// other initialization code, like creating http server
}

bootstrap(); // actually run the async function


The error I'm getting:

{ Error: Cannot find module './src/recipes/recipe.resolver.ts'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at filePaths.map.fileName (/Users/tamas.lorincz/Projects/graphql-test/node_modules/type-graphql/dist/helpers/loadResolversFromGlob.js:10:47)
at Array.map ()
at Object.loadResolversFromGlob (/Users/tamas.lorincz/Projects/graphql-test/node_modules/type-graphql/dist/helpers/loadResolversFromGlob.js:10:31)
at options.resolvers.forEach.resolver (/Users/tamas.lorincz/Projects/graphql-test/node_modules/type-graphql/dist/utils/buildSchema.js:36:37)
at Array.forEach ()
at loadResolvers (/Users/tamas.lorincz/Projects/graphql-test/node_modules/type-graphql/dist/utils/buildSchema.js:34:23) code: 'MODULE_NOT_FOUND' }
```

Anyone has faced this issue or knows how to resolve it?

Question Solved

Most helpful comment

      resolvers: [path.resolve(__dirname, '**', '*.resolver.{js,ts}')],

All 4 comments

      resolvers: [path.resolve(__dirname, '**', '*.resolver.{js,ts}')],

try that I find it more reliable

@thomsa-swi
Try to use the same path pattern with raw glob to see what files does it find, what path it generates, etc.

Closing for a housekeeping purposes 馃敀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichalLytek picture MichalLytek  路  3Comments

maplesteve picture maplesteve  路  3Comments

Janushan picture Janushan  路  3Comments

laukaichung picture laukaichung  路  3Comments

MichalLytek picture MichalLytek  路  3Comments