2017-04-08 14:17:49 -07:00
|
|
|
import { microGraphql, microGraphiql } from './microApollo';
|
|
|
|
import 'mocha';
|
|
|
|
|
2017-06-05 15:58:10 -06:00
|
|
|
import micro, { send } from 'micro';
|
|
|
|
import { router, get, post, put, patch, del, head, options as opts } from 'microrouter';
|
2017-07-17 16:29:40 -07:00
|
|
|
import testSuite, { schema, CreateAppOptions } from 'apollo-server-integration-testsuite';
|
2017-06-05 15:58:10 -06:00
|
|
|
|
2017-04-08 14:17:49 -07:00
|
|
|
|
|
|
|
function createApp(options: CreateAppOptions) {
|
2017-06-05 15:58:10 -06:00
|
|
|
const graphqlOptions = (options && options.graphqlOptions) || { schema };
|
|
|
|
const graphiqlOptions = (options && options.graphiqlOptions) || { endpointURL: '/graphql' };
|
|
|
|
|
|
|
|
const graphqlHandler = microGraphql(graphqlOptions);
|
|
|
|
const graphiqlHandler = microGraphiql(graphiqlOptions);
|
|
|
|
|
|
|
|
return micro(
|
|
|
|
router(
|
|
|
|
get('/graphql', graphqlHandler),
|
|
|
|
post('/graphql', graphqlHandler),
|
|
|
|
put('/graphql', graphqlHandler),
|
|
|
|
patch('/graphql', graphqlHandler),
|
|
|
|
del('/graphql', graphqlHandler),
|
|
|
|
head('/graphql', graphqlHandler),
|
|
|
|
opts('/graphql', graphqlHandler),
|
|
|
|
|
|
|
|
get('/graphiql', graphiqlHandler),
|
|
|
|
post('/graphiql', graphiqlHandler),
|
|
|
|
put('/graphiql', graphiqlHandler),
|
|
|
|
patch('/graphiql', graphiqlHandler),
|
|
|
|
del('/graphiql', graphiqlHandler),
|
|
|
|
head('/graphiql', graphiqlHandler),
|
|
|
|
opts('/graphiql', graphiqlHandler),
|
|
|
|
|
|
|
|
(req, res) => send(res, 404, 'not found'),
|
|
|
|
),
|
|
|
|
);
|
2017-04-08 14:17:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('integration:Micro', () => {
|
|
|
|
testSuite(createApp);
|
|
|
|
});
|