Type-graphql with lerna --- Error: Cannot determine GraphQL output type for id

Type-graphql with lerna --- Error: Cannot determine GraphQL output type for id

我最近从 yarn/workspaces 搬到了 lerna/npm,在那次搬迁中我发现了一个意想不到的问题。我知道得到:

Error: Cannot determine GraphQL output type for id 生成我的架构时

我正在使用 type-graphql 和 typeorm(很棒的组合)

我的包结构如下所示

/app
   /packages
       /utils (common functions)
       /data (my TypeORM entities, repos, factories, decorated with type-graphql)
       /server (my type-graphql server) deps on @app/data
       /server-test (tests my server) also deps on @app/data

在我做了一个之后: 勒纳清洁 CD app/packages/server npm 运行 开始

我现在得到 Error: Cannot determine GraphQL output type for id

数据和服务器的package.json均参考"type-graphql": "^0.17.4"

====== 注意:https://github.com/19majkel94/type-graphql/issues/69

@19majkel94 声明如下:

The last error Cannot determine GraphQL output type for id basically comes from getGraphQLOutputType and convertTypeIfScalar which performs if type instanceof GraphQLScalarType. The problem is that separate project has separate node_modules so GraphQLScalarType !== GraphQLScalarType.

From my experience there's always too much problems from separating things to projects/modules than the benefits of this. I would recommend restructuring your app to don't need this.

所以放弃 lerna 和模块化对我来说似乎有点核。我很想看看是否有办法使这项工作。

只需使用依赖提升,这样你所有的包都将使用根 node_modules 中的 graphql 模块。