Skip to content

Commit

Permalink
apollo-server-core: Improve a usage reporting misuse error
Browse files Browse the repository at this point in the history
This error generally should arise when people try to use the unexported AS 1.x
API instead of the 2.x API. (If we find other cases that trigger this error we
can update the linked issue.)

Fixes #4588.
  • Loading branch information
glasser committed Sep 24, 2020
1 parent 491c507 commit 4911354
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export function ApolloServerPluginUsageReporting<TContext>(
// this little hack. (Perhaps we should also allow GraphQLServerListener to contain
// a requestDidStart?)
requestDidStart(requestContext: GraphQLRequestContext<TContext>) {
if (!requestDidStartHandler) {
throw Error(
'The usage reporting plugin has been asked to handle a request before the ' +
'server has started. See https://github.com/apollographql/apollo-server/issues/4588 ' +
'for more details.',
);
}
return requestDidStartHandler(requestContext);
},

Expand Down

0 comments on commit 4911354

Please sign in to comment.