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

Throw error in applyMiddleware for vanilla apollo-server #1345

Merged
merged 1 commit into from
Jul 13, 2018
Merged
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
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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this calling super?

app,
path: '/',
bodyParserConfig: { limit: '50mb' },
Expand Down