Unable to use applyMiddleware (from graphql-middleware) after upgrading to 2.2.0

With a minimum graphql server with express, apollo-server 2.2.0 throws Error: Unable to generate server introspection document. while trying to apply middleware (graphql-shield) on the server with graphql-middleware

const { ApolloServer } = require('apollo-server-express');
const { makeExecutableSchema } = require('graphql-tools');
const { applyMiddleware } = require('graphql-middleware');
const { shield } = require('graphql-shield');

const typeDefs = `
	type Query {
		me: String!
	}

	type Mutation {
		test: String!
	}
`;
const resolvers = {
	Query: {
		me: () => 'me'
	},
	Mutation: {
		test: () => 'hi'
	}
};

const permissions = shield({
	Query: {
		me: true
	},
	Mutation: {
		test: true
	}
});

const schema = applyMiddleware(
	makeExecutableSchema({ typeDefs, resolvers }),
	permissions
);
const server = new ApolloServer({
	mocks: false,
	schema,
	context: ({ req }) => ({
		...req
	})
});
const app = express();
server.applyMiddleware({ app, path: '/graphql' });
app.listen({ port: 4000 }, () => {
	console.log(`???? Server ready at http://localhost:4000`);
});

which gives the following error:

/Users/hinsxd/projects/askmrfox/test/node_modules/apollo-server-core/dist/utils/schemaHash.js:16
        throw new Error('Unable to generate server introspection document.');
        ^

Error: Unable to generate server introspection document.
    at Object.generateSchemaHash (/Users/hinsxd/projects/askmrfox/test/node_modules/apollo-server-core/dist/utils/schemaHash.js:16:15)
    at new ApolloServerBase (/Users/hinsxd/projects/askmrfox/test/node_modules/apollo-server-core/dist/ApolloServer.js:157:40)
    at new ApolloServer (/Users/hinsxd/projects/askmrfox/test/node_modules/apollo-server-express/dist/ApolloServer.js:44:1)
    at Object.<anonymous> (/Users/hinsxd/projects/askmrfox/test/src/index.js:38:16)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
[nodemon] app crashed - waiting for file changes before starting...

Read more here: Source link