im trying to deploy Nestjs with Graphql backend server on Vercel, I am using schema first approach so there is a schema.graphql
and graphql.ts
in my src folder, you can see my code below, im following the nestjs docs to write my code, but it shows this error when deployed, can anyone help to fix it:
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: No type definitions were found with the specified file name patterns: "./**/*.graphql". Please make sure there is at least one file that matches the given patterns.","reason":{"errorType":"Error","errorMessage":"No type definitions were found with the specified file name patterns: "./**/*.graphql". Please make sure there is at least one file that matches the given patterns.","stack":["Error: No type definitions were found with the specified file name patterns: "./**/*.graphql".
generate-typings.ts
:
import { GraphQLDefinitionsFactory } from '@nestjs/graphql';
import { join } from 'path';
const definitionsFactory = new GraphQLDefinitionsFactory();
definitionsFactory.generate({
typePaths: ['./src/**/*.graphql'],
path: join(process.cwd(), 'src/graphql.ts'),
outputAs: 'class',
watch: true,
});
imports for app.module.ts
:
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
typePaths: ['./**/*.graphql'],
definitions: {
path: join(process.cwd(), 'src/graphql.ts'),
outputAs: 'class',
},
playground: false,
plugins: [ApolloServerPluginLandingPageLocalDefault()],
}),