I want to connect my frontend with backend by apollo server.
Schema is generated in backend main folder and i have following settings:
app.module:
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
autoSchemaFile: "schema.gql",
sortSchema: true,
playground: false,
}),
main.ts:
import { NestFactory } from '@nestjs/core';
import { GraphQLSchemaHost } from '@nestjs/graphql';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
const server = new ApolloServer(
{ schema: await app.get(GraphQLSchemaHost) }
);
await startStandaloneServer(server, {
listen: { port: 3000 },
});
}
bootstrap();
error from terminal:
Error: Expected {} to be a GraphQL schema.
How can i fix it?