Skip to content

Commit

Permalink
Throw error in applyMiddleware for vanilla apollo-server (#1345)
Browse files Browse the repository at this point in the history
  • Loading branch information
evans committed Jul 13, 2018
1 parent fbf6c6b commit a4c15d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/apollo-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ServerInfo {
}

export class ApolloServer extends ApolloServerBase {
private httpServer!: http.Server;
private httpServer: http.Server;
private cors?: CorsOptions | boolean;

constructor(config: Config & { cors?: CorsOptions | boolean }) {
Expand Down Expand Up @@ -80,14 +80,20 @@ export class ApolloServer extends ApolloServerBase {
return serverInfo;
}

public applyMiddleware() {
throw new Error(
'To use Apollo Server with an existing express application, please use apollo-server-express',
);
}

// Listen takes the same arguments as http.Server.listen.
public async listen(...opts: Array<any>): Promise<ServerInfo> {
// This class is the easy mode for people who don't create their own express
// object, so we have to create it.
const app = express();

// provide generous values for the getting started experience
this.applyMiddleware({
super.applyMiddleware({
app,
path: '/',
bodyParserConfig: { limit: '50mb' },
Expand Down

0 comments on commit a4c15d7

Please sign in to comment.