2016-07-28 20:19:39 -07:00
|
|
|
import * as connect from 'connect';
|
|
|
|
import * as bodyParser from 'body-parser';
|
2016-10-22 18:48:23 -07:00
|
|
|
import { graphqlConnect, graphiqlConnect } from './connectApollo';
|
2016-10-03 23:13:08 +03:00
|
|
|
import 'mocha';
|
2016-07-28 20:19:39 -07:00
|
|
|
|
2017-07-17 16:29:40 -07: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();
|
|
|
|
|
2016-10-22 23:52:32 -07:00
|
|
|
options.graphqlOptions = options.graphqlOptions || { schema: Schema };
|
2016-07-28 20:19:39 -07:00
|
|
|
if (!options.excludeParser) {
|
|
|
|
app.use('/graphql', bodyParser.json());
|
|
|
|
}
|
|
|
|
if (options.graphiqlOptions ) {
|
|
|
|
app.use('/graphiql', graphiqlConnect( options.graphiqlOptions ));
|
|
|
|
}
|
2016-10-20 21:16:53 +03:00
|
|
|
app.use('/graphql', require('connect-query')());
|
2016-10-22 23:52:32 -07:00
|
|
|
app.use('/graphql', graphqlConnect( options.graphqlOptions ));
|
2016-07-28 20:19:39 -07:00
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('integration:Connect', () => {
|
|
|
|
testSuite(createConnectApp);
|
|
|
|
});
|