Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move expressMiddleware to express4 deep import #6612

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions WIP/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ import http from 'http';
import cors from 'cors';
import { json } from 'body-parser';
import { ApolloServer, ApolloServerPluginDrainHttpServer } from '@apollo/server';
// TODO: Double check this import
import { expressMiddleware } from '@apollo/server/express';
import { expressMiddleware } from '@apollo/server/express4';
import { typeDefs, resolvers } from ('./schema');

const server = new ApolloServer({
Expand Down
8 changes: 8 additions & 0 deletions packages/server/express4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/express4",
"type": "module",
"main": "../dist/cjs/express4/index.js",
"module": "../dist/esm/express4/index.js",
"types": "../dist/esm/express4/index.d.ts",
"sideEffects": false
}
5 changes: 5 additions & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./express4": {
"types": "./dist/esm/express4/index.d.ts",
"import": "./dist/esm/express4/index.js",
"require": "./dist/cjs/express4/index.js"
},
"./standalone": {
"types": "./dist/esm/standalone/index.d.ts",
"import": "./dist/esm/standalone/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from 'express';
import request from 'supertest';
import { ApolloServer, expressMiddleware } from '../..';
import { ApolloServer } from '../..';
import { expressMiddleware } from '../../express4';

it('gives helpful error if body-parser middleware is not installed', async () => {
const server = new ApolloServer({ typeDefs: 'type Query {f: ID}' });
Expand Down
8 changes: 2 additions & 6 deletions packages/server/src/__tests__/express/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { json } from 'body-parser';
import cors from 'cors';
import express from 'express';
import http from 'http';
import {
ApolloServer,
ApolloServerOptions,
BaseContext,
expressMiddleware,
} from '../..';
import { ApolloServer, ApolloServerOptions, BaseContext } from '../..';
import { expressMiddleware } from '../../express4';
import { ApolloServerPluginDrainHttpServer } from '../../plugin/drainHttpServer';
import { urlForHttpServer } from '../../utils/urlForHttpServer';
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { json } from 'body-parser';
import cors from 'cors';
import express from 'express';
import http from 'http';
import {
ApolloServer,
ApolloServerOptions,
BaseContext,
expressMiddleware,
} from '../..';
import { ApolloServer, ApolloServerOptions, BaseContext } from '../..';
import { expressMiddleware } from '../../express4';
import { urlForHttpServer } from '../../utils/urlForHttpServer';
import type {
CreateServerForIntegrationTestsOptions,
Expand Down
3 changes: 0 additions & 3 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ export {
ForbiddenError,
UserInputError,
} from './errors.js';

// TODO(AS4): consider moving to `@apollo/server/express`
export { expressMiddleware } from './express/index.js';
2 changes: 1 addition & 1 deletion packages/server/src/standalone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import express from 'express';
import http, { IncomingMessage, ServerResponse } from 'http';
import type { ListenOptions } from 'net';
import type { ApolloServer } from '../ApolloServer';
import { expressMiddleware } from '../express/index.js';
import { expressMiddleware } from '../express4/index.js';
import type { BaseContext, ContextFunction } from '../externalTypes';
import { ApolloServerPluginDrainHttpServer } from '../plugin/drainHttpServer/index.js';
import { urlForHttpServer } from '../utils/urlForHttpServer.js';
Expand Down