Skip to content

Commit

Permalink
Allow other middleware (e.g. Playground) when initial Gateway load fa…
Browse files Browse the repository at this point in the history
…ils.

Another approach to this would be to throw an error here, but this is our
only opportunity to allow the server to recover after initial failure.

On the one hand, this approach is more graceful, but on the other hand,
perhaps we actually want initial failure (after timeouts elapse) to not bind
the other middleware.  Either way, the server doesn't just `process.exit`
right now, and with certain non-Node.js environments, it may be worthwhile
to operate in this mode.
  • Loading branch information
abernix committed Feb 27, 2020
1 parent 6c5c5bd commit b8901dc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,20 @@ export class ApolloServerBase {
}

protected async willStart() {
const { schema, schemaHash } = await this.schemaDerivedData;
try {
var { schema, schemaHash } = await this.schemaDerivedData;
} catch (err) {
// The `schemaDerivedData` can throw if the Promise it points to does not
// resolve with a `GraphQLSchema`. As errors from `willStart` are start-up
// errors, other Apollo middleware after us will not be called, including
// our health check, CORS, etc.
//
// Returning here allows the integration's other Apollo middleware to
// function properly in the event of a failure to obtain the data graph
// configuration from the gateway's `load` method during initialization.
return;
}

const service: GraphQLServiceContext = {
schema: schema,
schemaHash: schemaHash,
Expand Down

0 comments on commit b8901dc

Please sign in to comment.