diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e140869dc5..9c0a8eaf1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ The version headers in this history reflect the versions of Apollo Server itself > [See complete versioning details.](https://github.com/apollographql/apollo-server/commit/92ea402a90bf9817c9b887707abbd77dcf5edcb4) -- `apollo-server-koa`: Update `koa-bodyparser` dependency from `v3.0.0` to `v4.2.1` to fix inaccurate `Content-length` calculation. [PR #3229](https://github.com/apollographql/apollo-server/pull/3229) +- `apollo-server-koa`: **Drop support for Node.js v6 within the Apollo Server Koa integration in order to update `koa-bodyparser` dependency from `v3.0.0` to `v4.2.1`.** [PR #TODO](https://github.com/apollographql/apollo-server/pull/TODO) [Issue #3050](https://github.com/apollographql/apollo-server/issues/3050) [PR #3229](https://github.com/apollographql/apollo-server/pull/3229) - `apollo-server-express`: Use explicit return type for new `getMiddleware` method, in an effort to resolve [Issue #3222](https://github.com/apollographql/apollo-server/issues/3222) [PR #3230](https://github.com/apollographql/apollo-server/pull/3230) ### v2.9.1 diff --git a/packages/apollo-server-koa/src/__tests__/ApolloServer.test.ts b/packages/apollo-server-koa/src/__tests__/ApolloServer.test.ts index eb207fafde4..c95ee35b927 100644 --- a/packages/apollo-server-koa/src/__tests__/ApolloServer.test.ts +++ b/packages/apollo-server-koa/src/__tests__/ApolloServer.test.ts @@ -1,5 +1,3 @@ -import Koa from 'koa'; - import http from 'http'; import request from 'request'; @@ -8,7 +6,7 @@ import fs from 'fs'; import { createApolloFetch } from 'apollo-fetch'; import { gql, AuthenticationError, Config } from 'apollo-server-core'; -import { ApolloServer, ServerRegistration } from '../ApolloServer'; +import { ServerRegistration } from '../ApolloServer'; import { NODE_MAJOR_VERSION, @@ -28,9 +26,20 @@ const resolvers = { }, }; -describe('apollo-server-koa', () => { - let server; - let httpServer; +// If we're on Node.js v6, skip this test, since `koa-bodyparser` has dropped +// support for it and there was an important update to it which we brought in +// through https://github.com/apollographql/apollo-server/pull/3229. +// It's worth noting that Node.js v6 has been out of Long-Term-Support status +// for four months and is no longer recommended by the Node.js Foundation. +( + NODE_MAJOR_VERSION === 6 ? + describe.skip : + describe +)('apollo-server-koa', () => { + const { ApolloServer } = require('../ApolloServer'); + const Koa = require('koa'); + let server: ApolloServer; + let httpServer: http.Server; testApolloServer( async options => { server = new ApolloServer(options); @@ -48,23 +57,33 @@ describe('apollo-server-koa', () => { ); }); -describe('apollo-server-koa', () => { - let server: ApolloServer; - - let app: Koa; +// If we're on Node.js v6, skip this test, since `koa-bodyparser` has dropped +// support for it and there was an important update to it which we brought in +// through https://github.com/apollographql/apollo-server/pull/3229. +// It's worth noting that Node.js v6 has been out of Long-Term-Support status +// for four months and is no longer recommended by the Node.js Foundation. +( + NODE_MAJOR_VERSION === 6 ? + describe.skip : + describe +)('apollo-server-koa', () => { + const Koa = require('koa'); + const { ApolloServer } = require('../ApolloServer'); + let server: import('../ApolloServer').ApolloServer; + let app: import('koa'); let httpServer: http.Server; async function createServer( serverOptions: Config, - options: Partial = {}, + options: Partial = {}, ) { server = new ApolloServer(serverOptions); app = new Koa(); server.applyMiddleware({ ...options, app }); - httpServer = await new Promise(resolve => { - const l = app.listen({ port: 0 }, () => resolve(l)); + httpServer = await new Promise(resolve => { + const l: http.Server = app.listen({ port: 0 }, () => resolve(l)); }); return createServerInfo(server, httpServer); diff --git a/packages/apollo-server-koa/src/__tests__/datasource.test.ts b/packages/apollo-server-koa/src/__tests__/datasource.test.ts index a0ce2576464..41660a299ca 100644 --- a/packages/apollo-server-koa/src/__tests__/datasource.test.ts +++ b/packages/apollo-server-koa/src/__tests__/datasource.test.ts @@ -1,15 +1,15 @@ -import Koa from 'koa'; -import KoaRouter from 'koa-router'; - import http from 'http'; import { RESTDataSource } from 'apollo-datasource-rest'; import { createApolloFetch } from 'apollo-fetch'; -import { ApolloServer } from '../ApolloServer'; -import { createServerInfo } from 'apollo-server-integration-testsuite'; -import { gql } from '../index'; +import { + NODE_MAJOR_VERSION, + createServerInfo, +} from 'apollo-server-integration-testsuite'; + +import { gql } from 'apollo-server-core'; const restPort = 4002; @@ -43,27 +43,40 @@ const resolvers = { }, }; -let restCalls = 0; -const restAPI = new Koa(); -const router = new KoaRouter(); -router.all('/id/:id', ctx => { - const id = ctx.params.id; - restCalls++; - ctx.set('Cache-Control', 'max-age=2000, public'); - ctx.body = { id }; -}); +// If we're on Node.js v6, skip this test, since `koa-bodyparser` has dropped +// support for it and there was an important update to it which we brought in +// through https://github.com/apollographql/apollo-server/pull/3229. +// It's worth noting that Node.js v6 has been out of Long-Term-Support status +// for four months and is no longer recommended by the Node.js Foundation. +( + NODE_MAJOR_VERSION === 6 ? + describe.skip : + describe +)('apollo-server-koa', () => { + const { ApolloServer } = require('../ApolloServer'); + const Koa = require('koa'); + const KoaRouter = require('koa-router'); + + let restCalls = 0; + const restAPI = new Koa(); + const router = new KoaRouter(); + router.all('/id/:id', ctx => { + const id = ctx.params.id; + restCalls++; + ctx.set('Cache-Control', 'max-age=2000, public'); + ctx.body = { id }; + }); -router.all('/str/:id', ctx => { - const id = ctx.params.id; - restCalls++; - ctx.set('Cache-Control', 'max-age=2000, public'); - ctx.body = id; -}); + router.all('/str/:id', ctx => { + const id = ctx.params.id; + restCalls++; + ctx.set('Cache-Control', 'max-age=2000, public'); + ctx.body = id; + }); -restAPI.use(router.routes()); -restAPI.use(router.allowedMethods()); + restAPI.use(router.routes()); + restAPI.use(router.allowedMethods()); -describe('apollo-server-koa', () => { let restServer; beforeAll(async () => { @@ -76,7 +89,7 @@ describe('apollo-server-koa', () => { await restServer.close(); }); - let server: ApolloServer; + let server: import('../ApolloServer').ApolloServer; let httpServer: http.Server; beforeEach(() => { diff --git a/packages/apollo-server-koa/src/__tests__/koaApollo.test.ts b/packages/apollo-server-koa/src/__tests__/koaApollo.test.ts index 7a4594d3a9a..9c4fa74c7e6 100644 --- a/packages/apollo-server-koa/src/__tests__/koaApollo.test.ts +++ b/packages/apollo-server-koa/src/__tests__/koaApollo.test.ts @@ -1,12 +1,13 @@ -import Koa from 'koa'; -import { ApolloServer } from '../ApolloServer'; import testSuite, { + NODE_MAJOR_VERSION, schema as Schema, CreateAppOptions, } from 'apollo-server-integration-testsuite'; import { GraphQLOptions, Config } from 'apollo-server-core'; function createApp(options: CreateAppOptions = {}) { + const Koa = require('koa'); + const { ApolloServer } = require('../ApolloServer'); const app = new Koa(); const server = new ApolloServer( @@ -23,7 +24,17 @@ async function destroyApp(app) { await new Promise(resolve => app.close(resolve)); } -describe('koaApollo', () => { +// If we're on Node.js v6, skip this test, since `koa-bodyparser` has dropped +// support for it and there was an important update to it which we brought in +// through https://github.com/apollographql/apollo-server/pull/3229. +// It's worth noting that Node.js v6 has been out of Long-Term-Support status +// for four months and is no longer recommended by the Node.js Foundation. +( + NODE_MAJOR_VERSION === 6 ? + describe.skip : + describe +)('koaApollo', () => { + const { ApolloServer } = require('../ApolloServer'); it('throws error if called without schema', function() { expect(() => new ApolloServer(undefined as GraphQLOptions)).toThrow( 'ApolloServer requires options.', @@ -31,6 +42,15 @@ describe('koaApollo', () => { }); }); -describe('integration:Koa', () => { +// If we're on Node.js v6, skip this test, since `koa-bodyparser` has dropped +// support for it and there was an important update to it which we brought in +// through https://github.com/apollographql/apollo-server/pull/3229. +// It's worth noting that Node.js v6 has been out of Long-Term-Support status +// for four months and is no longer recommended by the Node.js Foundation. +( + NODE_MAJOR_VERSION === 6 ? + describe.skip : + describe +)('integration:Koa', () => { testSuite(createApp, destroyApp); });