I recently upgrade from apollo server 3 to 4 in my NestJS+gql+apollo server. I think I have fixed most breaking changes and the server starts up fine now.
However, doing queries from the frontend to the server now results in a CORS error.
Here is my GraphQLModule in my app.module.ts:
GraphQLModule.forRootAsync<ApolloDriverConfig>({
driver: ApolloDriver,
useFactory: async () => ({
typePaths: ['**/*.graphql'],
plugins: [ApolloServerPluginUsageReportingDisabled()],
introspection: process.env.NODE_ENV !== 'test',
context: args =>
process.env.NODE_ENV === 'test'
? mockContext(args)
: getContext(args),
cors: corsSettings,
}),
}),
I also have this in my main.ts:
app.enableCors(corsSettings);
Additionally, it does seem like the context in the GraphQLModule is called at all anymore, which I noticed when running my tests (no mock context was available).
Does anyone see any problem with my setup? I can provide more code if needed.
Thanks!