2018-06-11 14:25:59 +02:00
|
|
|
import connect from 'connect';
|
2018-06-13 15:19:08 -07:00
|
|
|
import query from 'qs-middleware';
|
|
|
|
import { ApolloServer, registerServer } from './ApolloServer';
|
|
|
|
import { Config } from 'apollo-server-core';
|
2016-10-03 23:13:08 +03:00
|
|
|
import 'mocha';
|
2016-07-28 20:19:39 -07:00
|
|
|
|
2018-01-09 00:08:01 +01:00
|
|
|
import testSuite, {
|
|
|
|
schema as Schema,
|
|
|
|
CreateAppOptions,
|
|
|
|
} from 'apollo-server-integration-testsuite';
|
2016-07-28 20:19:39 -07:00
|
|
|
|
|
|
|
function createConnectApp(options: CreateAppOptions = {}) {
|
|
|
|
const app = connect();
|
2018-06-13 15:19:08 -07:00
|
|
|
// We do require users of ApolloServer with connect to use a query middleware
|
|
|
|
// first. The alternative is to add a 'isConnect' bool to ServerRegistration
|
|
|
|
// and make qs-middleware be a dependency of this package. However, we don't
|
|
|
|
// think many folks use connect outside of Meteor anyway, and anyone using
|
|
|
|
// connect is probably already using connect-query or qs-middleware.
|
|
|
|
app.use(query());
|
|
|
|
const server = new ApolloServer(
|
|
|
|
(options.graphqlOptions as Config) || { schema: Schema },
|
|
|
|
);
|
|
|
|
// See comment on ServerRegistration.app for its typing.
|
|
|
|
registerServer({ app: app as any, server });
|
2016-07-28 20:19:39 -07:00
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('integration:Connect', () => {
|
|
|
|
testSuite(createConnectApp);
|
|
|
|
});
|