我正在尝试将nestjs 与棱镜集成。我按照nestjs文档中的教程进行操作。
一切正常,直到我想进行一些更改,因此nestjs 不会公开所有查询/突变模式。
我所做的是 1. 更新 app 模块不让 typePath 包含生成的架构
import { Module } from '@nestjs/common';
import { AppController } from 'app/app.controller';
import { AppService } from 'app/app.service';
import { GraphQLModule } from '@nestjs/graphql';
import { UserModule } from './user/user.module';
@Module({
imports: [
GraphQLModule.forRoot({
typePaths: ['./src/**/*.schema.graphql'],
debug: true,
playground: true,
}),
UserModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
2.然后我在文件夹中创建了一个user.schema.graphql
文件user
:
#import User from "../prisma/generated/prisma.graphql"
type Query {
user(id: ID!): User
}
但是,我收到一些错误,说我无法导入用户:
(node:36277) UnhandledPromiseRejectionWarning: Error: Type "User" not found in document.
at ASTDefinitionBuilder._resolveType (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:100:11)
at ASTDefinitionBuilder.buildType (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:210:79)
at ASTDefinitionBuilder._buildWrappedType (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:229:17)
at ASTDefinitionBuilder.buildField (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:249:18)
at /Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:332:21
at /Users/anx/Projects/axesk/gallery-api/node_modules/graphql/jsutils/keyValMap.js:36:31
at Array.reduce (<anonymous>)
at keyValMap (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/jsutils/keyValMap.js:35:15)
at ASTDefinitionBuilder._makeFieldDefMap (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:329:48)
at fields (/Users/anx/Projects/axesk/gallery-api/node_modules/graphql/utilities/buildASTSchema.js:312:22)
(node:36277) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:36277) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我是nestjs和graphql的新手,请帮忙!