HI @glasser
Thank you for the reply.
I am using apollo-server-express
The Config<ExpressContext>
is from apollo-server-express
, I checked it under apollo-server
V3.x
https://github.com/apollographql/apollo-server/commit/928f70906cb881e85caa2ae0e56d3dac61b20df0#diff-823979836b077954e7882625728ee8d656e227666f617f5471088e5cb4408412R42
To reproduce the error:
- packages
"dependencies": {
"@graphql-tools/schema": "^8.2.0",
"@graphql-tools/utils": "^8.2.2",
"apollo-server-express": "^3.3.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"debug": "^4.3.2",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"graphql": "^15.5.3",
"graphql-import-node": "^0.0.4",
"graphql-redis-subscriptions": "^2.4.0",
"graphql-subscriptions": "^1.2.1",
"helmet": "^4.6.0",
"lodash": "^4.17.21",
"morgan": "^1.10.0",
"subscriptions-transport-ws": "^0.9.19"
},
"devDependencies": {
"@types/chai": "^4.2.21",
"@types/cookie-parser": "^1.4.2",
"@types/debug": "^4.1.7",
"@types/express": "^4.17.13",
"@types/graphql": "^14.5.0",
"@types/lodash": "^4.14.172",
"@types/mocha": "^9.0.0",
"@types/morgan": "^1.9.3",
"@types/node": "^16.7.10",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"kill-port": "^1.6.1",
"mocha": "^9.1.1",
"nodemon": "^2.0.12",
"pg": "^8.7.1",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"supertest": "^6.1.6",
"ts-node": "^10.2.1",
"typeorm": "^0.2.37",
"typescript": "^4.4.2",
"wait-on": "^6.0.0"
}
- tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"outDir": "./dist",
"removeComments": true,
"isolatedModules": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"skipLibCheck": true,
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules"]
}
- coder
import {
ApolloServerPluginDrainHttpServer,
ApolloServerPluginLandingPageGraphQLPlayground,
ApolloServerPluginInlineTrace,
} from 'apollo-server-core';
import http, { Server } from 'http';
import { ApolloServer } from 'apollo-server-express';
import { SubscriptionServer } from 'subscriptions-transport-ws';
import { execute, subscribe } from 'graphql';
import config from './config';
import schema from './graphql';
const httpServer: Server = http.createServer();
const path = '/graphql';
const server = new ApolloServer({
schema,
introspection: true,
debug: config.graphql.debug,
plugins: [
{
async serverWillStart() {
return {
async drainServer() {
subscriptionServer.close();
},
};
},
},
ApolloServerPluginDrainHttpServer({ httpServer }),
ApolloServerPluginLandingPageGraphQLPlayground({}),
ApolloServerPluginInlineTrace(),
],
context: async () => {
return {};
},
});
const subscriptionServer = SubscriptionServer.create(
{
schema,
execute,
subscribe,
},
{
server: httpServer,
path,
},
);
....
Thank you for the support.